src/Controller/SecurityController.php line 13

  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.     #[Route('/'name'app_login')]
  10.     public function login(AuthenticationUtils $authenticationUtils): Response
  11.     {
  12.         $error $authenticationUtils->getLastAuthenticationError();
  13.         $lastUsername $authenticationUtils->getLastUsername();
  14.         return $this->render('@EasyAdmin/page/login.html.twig', [
  15.             // parameters usually defined in Symfony login forms
  16.             'error' => $error,
  17.             'last_username' => $lastUsername,
  18.             // OPTIONAL parameters to customize the login form:
  19.             // by default EasyAdmin displays a black square as its default favicon;
  20.             // use this method to display a custom favicon: the given path is passed
  21.             // "as is" to the Twig asset() function:
  22.             // <link rel="shortcut icon" href="{{ asset('...') }}">
  23.             //'favicon_path' => '/favicon-admin.svg',
  24.             // the title visible above the login form (define this option only if you are
  25.             // rendering the login template in a regular Symfony controller; when rendering
  26.             // it from an EasyAdmin Dashboard this is automatically set as the Dashboard title)
  27.             'page_title' => '<h2>Connexion</h2>',
  28.             // the string used to generate the CSRF token. If you don't define
  29.             // this parameter, the login form won't include a CSRF token
  30.             'csrf_token_intention' => 'authenticate',
  31.             // the URL users are redirected to after the login (default: '/admin')
  32.             'target_path' => $this->generateUrl('app_admin_dashboard'),
  33.             // the label displayed for the username form field (the |trans filter is applied to it)
  34.             'username_label' => 'Utilisateur',
  35.             // the label displayed for the password form field (the |trans filter is applied to it)
  36.             'password_label' => 'Mot de passe',
  37.             // the label displayed for the Sign In form button (the |trans filter is applied to it)
  38.             'sign_in_label' => 'Log in',
  39.             // whether to enable or not the "remember me" checkbox (default: false)
  40.             'remember_me_enabled' => true,
  41.             // the label displayed for the remember me checkbox (the |trans filter is applied to it)
  42.             'remember_me_label' => 'Se rappeler de moi',
  43.         ]);
  44.     }
  45.     #[Route('/logout'name'app_logout'methods: ['GET'])]
  46.     public function logout()
  47.     {
  48.         // controller can be blank: it will never be called!
  49.         throw new \Exception('Don\'t forget to activate logout in security.yaml');
  50.     }
  51. }