src/Controller/SecurityController.php line 85

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\MenuLibelle;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  9. class SecurityController extends AbstractController
  10. {
  11.     private mixed $params = [];
  12.     public function __construct(private EntityManagerInterface $em)
  13.     {
  14.     }
  15.     #[Route(path'/login'name'app_login'priority10)]
  16.     public function login(AuthenticationUtils $authenticationUtils): Response
  17.     {
  18.         $error $authenticationUtils->getLastAuthenticationError();
  19.         $lastUsername $authenticationUtils->getLastUsername();
  20.         $this->getMenusTop();
  21.         $this->getMenusProfile();
  22.         $this->params['is_pdf'] = 0;
  23.         $this->params['error'] = $error "Vos paramètres de connexion sont erronés" NULL;
  24.         //$this->params['lang'] = $this->translator->getLocale();
  25.         $this->params['show_screen_loader'] = 1;
  26.         $this->params['csrf_token_intention'] = 'authenticate';
  27.         return $this->render('Nordinfo/Main/login.html.twig'$this->params);
  28.         /*return $this->render('@EasyAdmin/page/login.html.twig', [
  29.             // parameters usually defined in Symfony login forms
  30.             'error' => $error,
  31.             'last_username' => $lastUsername,
  32.             // OPTIONAL parameters to customize the login form:
  33.             // the translation_domain to use (define this option only if you are
  34.             // rendering the login template in a regular Symfony controller; when
  35.             // rendering it from an EasyAdmin Dashboard this is automatically set to
  36.             // the same domain as the rest of the Dashboard)
  37.             'translation_domain' => 'admin',
  38.             // the title visible above the login form (define this option only if you are
  39.             // rendering the login template in a regular Symfony controller; when rendering
  40.             // it from an EasyAdmin Dashboard this is automatically set as the Dashboard title)
  41.             'page_title' => 'Nordinfo',
  42.             // the string used to generate the CSRF token. If you don't define
  43.             // this parameter, the login form won't include a CSRF token
  44.             'csrf_token_intention' => 'authenticate',
  45.             // the URL users are redirected to after the login (default: '/admin')
  46.             'target_path' => $this->generateUrl('admin'),
  47.             // the label displayed for the username form field (the |trans filter is applied to it)
  48.             'username_label' => 'Username',
  49.             // the label displayed for the password form field (the |trans filter is applied to it)
  50.             'password_label' => 'Mot de passe',
  51.             // the label displayed for the Sign In form button (the |trans filter is applied to it)
  52.             'sign_in_label' => 'Se connecter',
  53.             // the 'name' HTML attribute of the <input> used for the username field (default: '_username')
  54.             'username_parameter' => 'email',
  55.             // the 'name' HTML attribute of the <input> used for the password field (default: '_password')
  56.             'password_parameter' => 'password',
  57.         ]);*/
  58.     }
  59.     private function getMenusTop(): void
  60.     {
  61.         $this->params['menusTop'] = $this->em->getRepository(MenuLibelle::class)->findBy(['ordre' => 0]);
  62.     }
  63.     private function getMenusProfile(): void
  64.     {
  65.         $this->params['menusprofile'] = $this->em->getRepository(MenuLibelle::class)
  66.             ->getMenuProfile();
  67.     }
  68.     #[Route(path'/logout'name'app_logout'priority10)]
  69.     public function logout(): never
  70.     {
  71.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  72.     }
  73. }