29 lines
724 B
PHP
29 lines
724 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
require_once 'config.php';
|
|
|
|
// Handle CORS
|
|
header('Access-Control-Allow-Origin: *');
|
|
header('Access-Control-Allow-Methods: GET, OPTIONS');
|
|
header('Access-Control-Allow-Headers: Content-Type');
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
|
http_response_code(200);
|
|
exit();
|
|
}
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
|
$user = getCurrentUser();
|
|
|
|
if ($user) {
|
|
http_response_code(200);
|
|
die(json_encode(['success' => true, 'user' => $user]));
|
|
} else {
|
|
http_response_code(401);
|
|
die(json_encode(['success' => false, 'user' => null]));
|
|
}
|
|
}
|
|
|
|
http_response_code(405);
|
|
die(json_encode(['error' => 'Method not allowed']));
|