diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index f702897..0a36e36 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -325,6 +325,9 @@ class UserController extends AbstractController $user->setModifiedAt(new \DateTimeImmutable('now')); $this->userOrganizationService->deactivateAllUserOrganizationLinks($user, $actingUser); $user->setIsDeleted(true); + if($this->userService->isUserConnected($user)){ + $this->userService->revokeUserTokens($user->getUserIdentifier()); + } $this->entityManager->persist($user); $this->entityManager->flush(); $this->actionService->createAction("Delete user", $actingUser, null, $user->getUserIdentifier()); diff --git a/src/Service/UserService.php b/src/Service/UserService.php index 285b3f7..bd1e512 100644 --- a/src/Service/UserService.php +++ b/src/Service/UserService.php @@ -367,4 +367,16 @@ class UserService } return 'ROLE_' . $role; } + + public function revokeUserTokens(String $userIdentifier) + { + $tokens = $this->entityManager->getRepository(AccessToken::class)->findBy([ + 'userIdentifier' => $userIdentifier, + 'revoked' => false + ]); + + foreach ($tokens as $token) { + $token->revoke(); + } + } }