src/Controller/Admin/SecurityController.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Admin;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  6. /**
  7. * ══════════════════════════════════════════════════════════════════════════
  8. * CONNEXION AU NOUVEAU BACKOFFICE — /admin/login
  9. *
  10. * Le formulaire seulement. Le POST est traité par
  11. * `Security/LoginFormAuthenticator`, qui connaît la route `admin_login`
  12. * (même mécanisme que `backend_login`, l'ancien écran).
  13. *
  14. * Les champs `email`, `password`, `_csrf_token` (jeton `authenticate`)
  15. * sont imposés par l'authentificateur.
  16. * ══════════════════════════════════════════════════════════════════════════
  17. */
  18. class SecurityController extends AbstractController
  19. {
  20. public function login(AuthenticationUtils $auth): Response
  21. {
  22. if ($this->isGranted('ROLE_ADMIN')) {
  23. return $this->redirectToRoute('admin_dashboard');
  24. }
  25. return $this->render('admin/login.html.twig', [
  26. 'derniereErreur' => $auth->getLastAuthenticationError(),
  27. 'dernierEmail' => $auth->getLastUsername(),
  28. ]);
  29. }
  30. }