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("/", name="app_login")
  11.      */
  12.     public function login(AuthenticationUtils $authenticationUtils): Response
  13.     {
  14.          if ($this->getUser()) {
  15.              return $this->redirectToRoute('user');
  16.          }
  17.         // get the login error if there is one
  18.         $error $authenticationUtils->getLastAuthenticationError();
  19.         // last username entered by the user
  20.         $lastUsername $authenticationUtils->getLastUsername();
  21.         //return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
  22.         return $this->render('bundles/EasyAdminBundle/crud/page/login.html.twig', [
  23.             // parameters usually defined in Symfony login forms
  24.             'error' => $error,
  25.             'last_username' => $lastUsername,
  26.             // OPTIONAL parameters to customize the login form:
  27.             // the translation_domain to use (define this option only if you are
  28.             // rendering the login template in a regular Symfony controller; when
  29.             // rendering it from an EasyAdmin Dashboard this is automatically set to
  30.             // the same domain as the rest of the Dashboard)
  31.             //'translation_domain' => 'admin',
  32.             // the title visible above the login form (define this option only if you are
  33.             // rendering the login template in a regular Symfony controller; when rendering
  34.             // it from an EasyAdmin Dashboard this is automatically set as the Dashboard title)
  35.             //'page_title' => '<img src="images/logosm.png"> HSE Conform LOGIN',
  36.             'page_title' => 'HSE Conform LOGIN',
  37.             // the string used to generate the CSRF token. If you don't define
  38.             // this parameter, the login form won't include a CSRF token
  39.             'csrf_token_intention' => 'authenticate',
  40.             // the URL users are redirected to after the login (default: '/admin')
  41.             //'target_path' => $this->generateUrl('admin_dashboard'),
  42.             // the label displayed for the username form field (the |trans filter is applied to it)
  43.             'username_label' => 'Login',
  44.             // the label displayed for the password form field (the |trans filter is applied to it)
  45.             'password_label' => 'Mot de passe',
  46.             // the label displayed for the Sign In form button (the |trans filter is applied to it)
  47.             'sign_in_label' => 'Se connecter',
  48.             // the 'name' HTML attribute of the <input> used for the username field (default: '_username')
  49.             'username_parameter' => 'username',
  50.             // the 'name' HTML attribute of the <input> used for the password field (default: '_password')
  51.             'password_parameter' => 'password',
  52.         ]);
  53.     }
  54.     /**
  55.      * @Route("/logout", name="app_logout")
  56.      */
  57.     public function logout()
  58.     {
  59.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  60.     }
  61. }