userModel = new UserModel(); } public function __invoke(ServerRequestInterface $request) { $userId = (int) ($request->getAttribute('user_id') ?? 0); if ($userId <= 0) { return ResponseLib::sendFail("Unauthorized: Missing authenticated user", [], "E_VALIDATE")->withStatus(401); } $profile = $this->userModel->getAuthenticatedProfile($userId); if (!$profile) { return ResponseLib::sendFail("User not found", [], "E_NOT_FOUND")->withStatus(404); } return ResponseLib::sendOk($profile); } }