(array $input)
| 15 | class UserGetController implements ControllerInterface |
| 16 | { |
| 17 | public function __invoke(array $input): ResponseInterface |
| 18 | { |
| 19 | // Check if authentication is enabled (any user exists) |
| 20 | $repository = ServiceContainer::get(Repository::class); |
| 21 | $auth_enabled = $repository->userTableNotEmpty(); |
| 22 | |
| 23 | if (!$auth_enabled) { |
| 24 | return data([ |
| 25 | 'message' => 'User has not been created.', |
| 26 | 'data' => [ |
| 27 | 'user' => null, |
| 28 | ], |
| 29 | ], 200); |
| 30 | } |
| 31 | |
| 32 | $user = getLoggedInUser(); |
| 33 | |
| 34 | if (!$user) { |
| 35 | throw new UnauthorizedException('No user is currently logged in.'); |
| 36 | } |
| 37 | |
| 38 | return success('User retrieved successfully.', [ |
| 39 | 'user' => buildPublicUserObject($user) |
| 40 | ]); |
| 41 | } |
| 42 | } |
nothing calls this directly
no test coverage detected