src/Controller/SecurityController.php line 19

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. use Symfony\Component\HttpFoundation\Request;
  8. class SecurityController extends AbstractController
  9. {
  10.     /**
  11.      * @Route({"en": "/login", "es": "/acceso"}, 
  12.      *         name="app_login")
  13.      * 
  14.      * @Route("/login", name="app_login")
  15.      */
  16.     public function login(AuthenticationUtils $authenticationUtilsRequest $request): Response
  17.     {
  18.         if ($this->getUser()) {
  19.             return $this->redirectToRoute('app_index');
  20.         }
  21.         // get the login error if there is one
  22.         $error $authenticationUtils->getLastAuthenticationError();
  23.         // last username entered by the user
  24.         $lastUsername $authenticationUtils->getLastUsername();
  25.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  26.     }
  27.     /**
  28.      * @Route("/logout", name="app_logout")
  29.      */
  30.     public function logout()
  31.     {
  32.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  33.     }
  34. }