src/Controller/SecurityController.php line 13

  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.     #[Route('/login'name'app_login')]
  10.     public function login(AuthenticationUtils $auth): Response
  11.     {
  12.         $error $auth->getLastAuthenticationError();
  13.         $lastUsername $auth->getLastUsername();
  14.         return $this->render('login/login.html.twig', [
  15.             'last_username' => $lastUsername,
  16.             'error' => $error,
  17.         ]);
  18.     }
  19.     #[Route('/logout'name'app_logout'methods: ['GET'])]
  20.     public function logout()
  21.     {
  22.         // controller can be blank: it will never be called!
  23.         throw new \Exception('Do not forget to activate logout in security.yaml');
  24.     }
  25. }