src/Controller/SecurityController.php line 14

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. class SecurityController extends AbstractController
  8. {
  9. /**
  10. * @Route("/", name="app_login")
  11. */
  12. public function login(AuthenticationUtils $authenticationUtils): Response
  13. {
  14. $error = $authenticationUtils->getLastAuthenticationError();
  15. $lastUsername = $authenticationUtils->getLastUsername();
  16. return $this->render('@EasyAdmin/page/login.html.twig', [
  17. // parameters usually defined in Symfony login forms
  18. 'error' => $error,
  19. 'last_username' => $lastUsername,
  20. // OPTIONAL parameters to customize the login form:
  21. // the translation_domain to use (define this option only if you are
  22. // rendering the login template in a regular Symfony controller; when
  23. // rendering it from an EasyAdmin Dashboard this is automatically set to
  24. // the same domain as the rest of the Dashboard)
  25. 'translation_domain' => 'admin',
  26. // by default EasyAdmin displays a black square as its default favicon;
  27. // use this method to display a custom favicon: the given path is passed
  28. // "as is" to the Twig asset() function:
  29. // <link rel="shortcut icon" href="{{ asset('...') }}">
  30. 'favicon_path' => '/favicon-admin.svg',
  31. // the title visible above the login form (define this option only if you are
  32. // rendering the login template in a regular Symfony controller; when rendering
  33. // it from an EasyAdmin Dashboard this is automatically set as the Dashboard title)
  34. 'page_title' => '',
  35. // the string used to generate the CSRF token. If you don't define
  36. // this parameter, the login form won't include a CSRF token
  37. 'csrf_token_intention' => 'authenticate',
  38. // the URL users are redirected to after the login (default: '/admin')
  39. 'target_path' => $this->generateUrl('admin'),
  40. // the label displayed for the username form field (the |trans filter is applied to it)
  41. 'username_label' => 'Identifiant',
  42. // the label displayed for the password form field (the |trans filter is applied to it)
  43. 'password_label' => 'Mot de passe',
  44. // the label displayed for the Sign In form button (the |trans filter is applied to it)
  45. 'sign_in_label' => 'Connexion',
  46. // the 'name' HTML attribute of the <input> used for the username field (default: '_username')
  47. //'username_parameter' => 'email',
  48. // the 'name' HTML attribute of the <input> used for the password field (default: '_password')
  49. //'password_parameter' => 'password',
  50. // whether to enable or not the "forgot password?" link (default: false)
  51. 'forgot_password_enabled' => true,
  52. // the path (i.e. a relative or absolute URL) to visit when clicking the "forgot password?" link (default: '#')
  53. //'forgot_password_path' => $this->generateUrl('...', ['...' => '...']),
  54. // the label displayed for the "forgot password?" link (the |trans filter is applied to it)
  55. 'forgot_password_label' => 'Mot de passe oubliƩ ?',
  56. // whether to enable or not the "remember me" checkbox (default: false)
  57. 'remember_me_enabled' => true,
  58. // remember me name form field (default: '_remember_me')
  59. 'remember_me_parameter' => 'custom_remember_me_param',
  60. // whether to check by default the "remember me" checkbox (default: false)
  61. 'remember_me_checked' => true,
  62. // the label displayed for the remember me checkbox (the |trans filter is applied to it)
  63. 'remember_me_label' => 'Remember me',
  64. ]);
  65. }
  66. #[Route(path: '/logout', name: 'app_logout')]
  67. public function logout(): void
  68. {
  69. throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  70. }
  71. }