get('/auth/session', function () { ScopeMiddleware::requireScope(Scope::CUSTOMER_READ, '/auth/session'); // Require the user to be logged in global $response; $this->requirePermission('fetch_session'); // Get the user object $user = (new authentication())->get_user(); // Check if the request was successful if ($user) { // Log the incident (new logs_o())->add('auth', 'global', 1, $user->id, 'FETCH_SESSION', 'User id: ' . $user->id); // Return the user object $response->success($user); } else { // Log the incident (new logs_o())->add('auth', 'global', 1, 0, 'FETCH_SESSION_FAILURE', 'No user found, or invalid session'); // Return an error $response->error('Invalid session', 400); } }, [ 'fetch_session' => 'Fetch session' ] ); } }