From 45936f24ae54bc609cbe054a4324bf5320ff5743 Mon Sep 17 00:00:00 2001 From: Edward Ly Date: Wed, 9 Oct 2024 22:32:43 -0700 Subject: [PATCH] feat(ApiController): add endpoint to de-provision user Signed-off-by: Edward Ly --- lib/Controller/ApiController.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index 5b74d6d5..1bacc823 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -97,4 +97,18 @@ public function createUser(int $providerId, string $userId, ?string $displayName return new DataResponse(['user_id' => $user->getUID()]); } + + /** + * @param string $userId + * @return DataResponse + */ + #[FrontpageRoute(verb: 'DELETE', url: '/user/{userId}')] + public function deleteUser(string $userId): DataResponse { + $user = $this->userManager->get($userId); + if (!is_null($user)) { + $user->delete(); + } + + return new DataResponse(['user_id' => $userId]); + } }