diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index fbe7274..7ce7d66 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -279,4 +279,23 @@ class UserController extends AbstractController throw $this->createAccessDeniedException(self::ACCESS_DENIED); } + + #[Route('/delete/{id}', name: 'delete', methods: ['GET'])] + public function delete(int $id, Request $request): Response + { + $this->denyAccessUnlessGranted("ROLE_SUPER_ADMIN"); + $actingUser = $this->userService->getUserByIdentifier($this->getUser()->getUserIdentifier()); + $user = $this->entityManager->getRepository(User::class)->find($id); + if (!$user) { + throw $this->createNotFoundException(self::NOT_FOUND); + } + $user->setIsActive(false); + $user->setModifiedAt(new \DateTimeImmutable('now')); + $this->userOrganizationService->deactivateAllUserOrganizationLinks($user, $actingUser); + $user->setIsDeleted(true); + $this->entityManager->persist($user); + $this->entityManager->flush(); + $this->actionService->createAction("Delete user", $actingUser, null, $user->getUserIdentifier()); + return $this->redirectToRoute('user_index'); + } } diff --git a/templates/user/show.html.twig b/templates/user/show.html.twig index ca1c3b1..6f80ce7 100644 --- a/templates/user/show.html.twig +++ b/templates/user/show.html.twig @@ -3,10 +3,18 @@ {% block body %}
+ + {% if is_granted("ROLE_ADMIN") %}

Gestion Utilisateur

- Désactiver +
+ {% if is_granted("ROLE_SUPER_ADMIN") %} + Supprimer + {% endif %} + Désactiver +
+
{% endif %} {% include 'user/userInformation.html.twig' %} @@ -15,12 +23,12 @@

Vos applications

{% elseif orgs|length == 1 %} {% for org in orgs %} -

{{ org.name }}

+

{{ org.name }}

{% endfor %} {% else %}

Aucune application

{% endif %} -
+
{% for uoa in uoas %} {% include 'user/application/information.html.twig' %} {% endfor %}