src/Controller/SecurityController.php line 15

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