From a992c2ea6a2cb0ba654998e38bee274d41e0b395 Mon Sep 17 00:00:00 2001 From: sermandm Date: Thu, 8 May 2025 13:58:02 +0200 Subject: [PATCH] =?UTF-8?q?R=C3=A9paration=20du=20DashboardController=20et?= =?UTF-8?q?=20AuthenticationController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/AuthenticationController.php | 16 ++++++++++------ src/Controller/DashboardController.php | 9 ++++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Controller/AuthenticationController.php b/src/Controller/AuthenticationController.php index ffc40ab..32d7731 100644 --- a/src/Controller/AuthenticationController.php +++ b/src/Controller/AuthenticationController.php @@ -3,27 +3,31 @@ namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; class AuthenticationController extends AbstractController { - #[Route(path: '/login', name: 'app_login')] + #[Route(path: '/', name: 'app_login')] public function login(AuthenticationUtils $authenticationUtils): Response { - // get the login error if there is one + if ($this->getUser()) { + return $this->redirectToRoute('dashboard'); + } + $error = $authenticationUtils->getLastAuthenticationError(); - // last username entered by the user $lastUsername = $authenticationUtils->getLastUsername(); - return $this->render('authentication/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]); + return $this->render('login/index.html.twig', [ + 'last_username' => $lastUsername, + 'error' => $error, + ]); } #[Route(path: '/logout', name: 'app_logout')] public function logout(): void { - throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.'); + throw new \LogicException('Cette méthode est interceptée par Symfony pour déconnecter.'); } } diff --git a/src/Controller/DashboardController.php b/src/Controller/DashboardController.php index 729bd41..2316f9f 100644 --- a/src/Controller/DashboardController.php +++ b/src/Controller/DashboardController.php @@ -10,18 +10,21 @@ use Symfony\Component\Routing\Annotation\Route; class DashboardController extends AbstractController { #[Route('/', name: 'dashboard')] + #[Route('/admin', name: 'admin_dashboard')] + #[Route('/secretaire', name: 'secretaire_dashboard')] + #[Route('/chauffagiste', name: 'chauffagiste_dashboard')] public function index(): Response { if ($this->isGranted('ROLE_ADMIN')) { - return $this->render('admin.html.twig'); + return $this->render('dashboard/admin.html.twig'); } if ($this->isGranted('ROLE_SECRETAIRE')) { - return $this->render('secretaire.html.twig'); + return $this->render('dashboard/secretaire.html.twig'); } if ($this->isGranted('ROLE_CHAUFFAGISTE')) { - return $this->render('chauffagiste.html.twig'); + return $this->render('dashboard/chauffagiste.html.twig'); } throw $this->createAccessDeniedException('Vous ne pouvez pas accéder à ce tableau de bord.');