MCPcopy Create free account
hub / github.com/denho/faved / __invoke

Method __invoke

controllers/UserDeleteController.php:15–45  ·  view source on GitHub ↗
(array $input)

Source from the content-addressed store, hash-verified

13class 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}

Callers

nothing calls this directly

Calls 6

dataFunction · 0.85
getLoggedInUserFunction · 0.85
logoutUserFunction · 0.85
getMethod · 0.80
userTableNotEmptyMethod · 0.80
deleteUserMethod · 0.80

Tested by

no test coverage detected