src/Controller/SecurityController.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  7. /**
  8.  * @Route("/{_locale}", requirements={"_locale": "ar|fr"})
  9.  */
  10. class SecurityController extends AbstractController
  11. {
  12.     #[Route(path'/'name'locale_login')]
  13.     public function localeLog(AuthenticationUtils $authenticationUtils): Response
  14.     {
  15.         return $this->redirectToRoute('login');
  16.     }
  17.     #[Route(path'/login'name'login')]
  18.     public function loginUser(AuthenticationUtils $authenticationUtils): Response
  19.     {
  20.         // if ($this->getUser()) {
  21.         //     return $this->redirectToRoute('target_path');
  22.         // }
  23.         // get the login error if there is one
  24.         $error $authenticationUtils->getLastAuthenticationError();
  25.         // last username entered by the user
  26.         $lastUsername $authenticationUtils->getLastUsername();
  27.         return $this->render('security/login_global.html.twig', ['last_username' => $lastUsername'error' => $error]);
  28.     }
  29.     #[Route(path'/logout'name'logout')]
  30.     public function logoutUser(): void
  31.     {
  32.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  33.     }
  34.     #[Route(path'/admin/login'name'admin_login')]
  35.     public function loginAdmin(AuthenticationUtils $authenticationUtils): Response
  36.     {
  37.         // if ($this->getUser()) {
  38.         //     return $this->redirectToRoute('target_path');
  39.         // }
  40.         // get the login error if there is one
  41.         $error $authenticationUtils->getLastAuthenticationError();
  42.         // last username entered by the user
  43.         $lastUsername $authenticationUtils->getLastUsername();
  44.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  45.     }
  46.     #[Route(path'/admin/logout'name'admin_logout')]
  47.     public function logoutAdmin(): void
  48.     {
  49.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  50.     }
  51.     #[Route(path'/inseminateur/login'name'inseminateur_login')]
  52.     public function loginInseminateur(AuthenticationUtils $authenticationUtils): Response
  53.     {
  54.         $error $authenticationUtils->getLastAuthenticationError();
  55.         // last username entered by the user
  56.         $lastUsername $authenticationUtils->getLastUsername();
  57.         return $this->render('security/login_inseminateur.html.twig', ['last_username' => $lastUsername'error' => $error]);
  58.     }
  59.     #[Route(path'/inseminateur/logout'name'inseminateur_logout')]
  60.     public function logoutInseminateur(): void
  61.     {
  62.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  63.     }
  64.     #[Route(path'/agentOEP/login'name'agent_oep_login')]
  65.     public function loginAgentOEP(AuthenticationUtils $authenticationUtils): Response
  66.     {
  67.         $error $authenticationUtils->getLastAuthenticationError();
  68.         // last username entered by the user
  69.         $lastUsername $authenticationUtils->getLastUsername();
  70.         return $this->render('security/login_agent_oep.html.twig', ['last_username' => $lastUsername'error' => $error]);
  71.     }
  72.     #[Route(path'/agentOEP/logout'name'agent_oep_logout')]
  73.     public function logoutAgentOEP(): void
  74.     {
  75.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  76.     }
  77.     #[Route(path'/agent/login'name'agent_login')]
  78.     public function loginAgent(AuthenticationUtils $authenticationUtils): Response
  79.     {
  80.         $error $authenticationUtils->getLastAuthenticationError();
  81.         // last username entered by the user
  82.         $lastUsername $authenticationUtils->getLastUsername();
  83.         return $this->render('security/login_agent.html.twig', ['last_username' => $lastUsername'error' => $error]);
  84.     }
  85.     #[Route(path'/agent/logout'name'agent_logout')]
  86.     public function logoutAgent(): void
  87.     {
  88.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  89.     }
  90.     #[Route(path'/eleveur/login'name'eleveur_login')]
  91.     public function loginEleveur(AuthenticationUtils $authenticationUtils): Response
  92.     {
  93.         $error $authenticationUtils->getLastAuthenticationError();
  94.         // last username entered by the user
  95.         $lastUsername $authenticationUtils->getLastUsername();
  96.         return $this->render('security/login_eleveur.html.twig', ['last_username' => $lastUsername'error' => $error]);
  97.     }
  98.     #[Route(path'/eleveur/logout'name'eleveur_logout')]
  99.     public function logoutEleveur(): void
  100.     {
  101.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  102.     }
  103. }