src/Controller/SecurityController.php line 15

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("/login", name="login")
  11.      */
  12.     public function login(AuthenticationUtils $authenticationUtils): Response
  13.     {
  14.         if ($this->getUser()) {
  15.             return $this->redirectToRoute('admin');
  16.         }
  17.         $error $authenticationUtils->getLastAuthenticationError();
  18.         $lastUsername $authenticationUtils->getLastUsername();
  19.         return $this->render('admin/page/login.html.twig', [
  20.             'error' => $error,
  21.             'last_username' => $lastUsername,
  22.             // OPTIONAL parameters to customize the login form:
  23.             // the translation_domain to use (define this option only if you are
  24.             // rendering the login template in a regular Symfony controller; when
  25.             // rendering it from an EasyAdmin Dashboard this is automatically set to
  26.             // the same domain as the rest of the Dashboard)
  27.             'translation_domain' => 'admin',
  28.             // the title visible above the login form (define this option only if you are
  29.             // rendering the login template in a regular Symfony controller; when rendering
  30.             // it from an EasyAdmin Dashboard this is automatically set as the Dashboard title)
  31.             'page_title' => $this->getParameter('app_name'),
  32.             // the string used to generate the CSRF token. If you don't define
  33.             // this parameter, the login form won't include a CSRF token
  34.             'csrf_token_intention' => 'authenticate',
  35.             // the URL users are redirected to after the login (default: '/admin')
  36.             'target_path' => $this->generateUrl('admin'),
  37.             // the label displayed for the username form field (the |trans filter is applied to it)
  38.             'username_label' => 'Email',
  39.             // the label displayed for the password form field (the |trans filter is applied to it)
  40.             'password_label' => 'ContraseƱa',
  41.             // the label displayed for the Sign In form button (the |trans filter is applied to it)
  42.             'sign_in_label' => 'Log in',
  43.             // the 'name' HTML attribute of the <input> used for the username field (default: '_username')
  44.             'username_parameter' => 'email',
  45.             // the 'name' HTML attribute of the <input> used for the password field (default: '_password')
  46.             'password_parameter' => 'password',
  47.             // whether to enable or not the "forgot password?" link (default: false)
  48.             'forgot_password_enabled' => false,
  49.             // the path (i.e. a relative or absolute URL) to visit when clicking the "forgot password?" link (default: '#')
  50.             // 'forgot_password_path' => $this->generateUrl('...', ['...' => '...']),
  51.             // the label displayed for the "forgot password?" link (the |trans filter is applied to it)
  52.             'forgot_password_label' => 'Forgot your password?',
  53.             // whether to enable or not the "remember me" checkbox (default: false)
  54.             'remember_me_enabled' => false,
  55.             // remember me name form field (default: '_remember_me')
  56.             'remember_me_parameter' => 'custom_remember_me_param',
  57.             // whether to check by default the "remember me" checkbox (default: false)
  58.             'remember_me_checked' => true,
  59.             // the label displayed for the remember me checkbox (the |trans filter is applied to it)
  60.             'remember_me_label' => 'Remember me',
  61.         ]);
  62.     }
  63.     /**
  64.      * @Route("/logout", name="logout")
  65.      */
  66.     public function logout(): void
  67.     {
  68.     }
  69. }