enable account deletion

This commit is contained in:
2026-02-10 16:46:08 +01:00
parent 2b5446555b
commit 0bde09ad5c
3 changed files with 28 additions and 8 deletions
@@ -127,14 +127,16 @@ class UsersController extends ApiController
*/
public function destroy(User $user)
{
if ($user->id == auth()->id()) {
return $this->errorForbidden(__("You cannot delete yourself."));
try {
event(new Deleted($user));
$user->delete();
return $this->respondWithSuccess();
} catch (\Illuminate\Database\QueryException $e) {
return $this->errorInternal($e->getMessage());
} catch (\Exception $e) {
return $this->errorInternal($e->getMessage());
}
event(new Deleted($user));
$this->users->delete($user->id);
return $this->respondWithSuccess();
}
}