(array $input)
| 13 | class UserDeleteController implements ControllerInterface |
| 14 | { |
| 15 | public function __invoke(array $input): ResponseInterface |
| 16 | { |
| 17 | // Check if authentication is enabled (any user exists) |
| 18 | $repository = ServiceContainer::get(Repository::class); |
| 19 | $auth_enabled = $repository->userTableNotEmpty(); |
| 20 | |
| 21 | if (!$auth_enabled) { |
| 22 | return data([ |
| 23 | 'success' => false, |
| 24 | 'message' => 'Authentication is disabled. Please set up a user account first.', |
| 25 | ], 400); |
| 26 | } |
| 27 | |
| 28 | $user = getLoggedInUser(); |
| 29 | |
| 30 | $result = $repository->deleteUser($user['id']); |
| 31 | |
| 32 | if (! $result) { |
| 33 | return data([ |
| 34 | 'success' => false, |
| 35 | 'message' => 'Failed to disable authentication.', |
| 36 | ], 500); |
| 37 | } |
| 38 | |
| 39 | logoutUser(); |
| 40 | |
| 41 | return data([ |
| 42 | 'success' => true, |
| 43 | 'message' => 'Authentication disabled successfully.', |
| 44 | ], 200); |
| 45 | } |
| 46 | } |
nothing calls this directly
no test coverage detected