diff --git a/panel/api/endpoints/auth.php b/panel/api/endpoints/auth.php index 3d4808b..a1a7f3e 100644 --- a/panel/api/endpoints/auth.php +++ b/panel/api/endpoints/auth.php @@ -31,13 +31,16 @@ match ($action) { Response::success(null, 'Logged out'); })(), - 'me' => (function() use ($currentUser) { + 'me' => (function() { + $auth = Auth::getInstance(); + if (!$auth->check()) Response::error('Unauthorized', 401); + $u = $auth->user(); Response::success([ - 'id' => $currentUser['uid'], - 'username' => $currentUser['username'], - 'email' => $currentUser['email'], - 'role' => $currentUser['role'], - 'theme' => $currentUser['theme'], + 'id' => $u['uid'] ?? $u['id'], + 'username' => $u['username'], + 'email' => $u['email'], + 'role' => $u['role'], + 'theme' => $u['theme'], ]); })(),