src/Controller/SecurityController.php line 80

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