src/Controller/Publico/SecurityController.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Publico;
  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.     public const BASEDIR '/pages/publico/security';
  11.     /**
  12.      * @Route("/acceder", name="app_login")
  13.      */
  14.     public function login(AuthenticationUtils $authenticationUtilsRequest $request): Response
  15.     {
  16.         if ($this->getUser()) {
  17.             return $this->redirectToRoute('index');
  18.         }
  19.         
  20.         // get the login error if there is one
  21.         $error $authenticationUtils->getLastAuthenticationError();
  22.         // last username entered by the user
  23.         $lastUsername $authenticationUtils->getLastUsername();
  24.         return $this->render(self::BASEDIR.'/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  25.     }
  26.     /**
  27.      * @Route("/salir", name="app_logout")
  28.      */
  29.     public function logout(): void
  30.     {
  31.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  32.     }
  33. }