src/Controller/Security/AuthController.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Security;
  3. use Symfony\Component\HttpFoundation\Response;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  7. class AuthController extends AbstractController
  8.     /**
  9.      * Login a user using a form and Twig
  10.      * 
  11.      * @Route("/login", name="app_login")
  12.      */
  13.     public function login(AuthenticationUtils $authenticationUtils): Response
  14.     {
  15.         // get the login error if there is one
  16.         $error $authenticationUtils->getLastAuthenticationError();
  17.         // last username entered by the user
  18.         $lastUsername $authenticationUtils->getLastUsername();
  19.         return $this->render('login_form.html.twig', ['last_username' => $lastUsername'error' => $error]);
  20.     }
  21.     /**
  22.      * Log out a user
  23.      * 
  24.      * @Route("/logout", name="app_logout")
  25.      */
  26.     public function logout()
  27.     {   
  28.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  29.         
  30.     }
  31. }