src/Controller/SecurityController.php line 17

Open in your IDE?
  1. <?php
  2. // src/Controller/SecurityController.php
  3. namespace App\Controller;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  8. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  9. class SecurityController extends AbstractController
  10. {
  11. /**
  12. * @Route("/login", name="app_login")
  13. */
  14. public function login(AuthenticationUtils $authenticationUtils): Response
  15. {
  16. // get the login error if there is one
  17. $error = $authenticationUtils->getLastAuthenticationError();
  18. // last username entered by the user
  19. $lastUsername = $authenticationUtils->getLastUsername();
  20. return $this->render('security/login.html.twig', [
  21. 'last_username' => $lastUsername,
  22. 'error' => $error
  23. ]);
  24. }
  25. /**
  26. * @Route("/logout", name="app_logout", methods={"GET"})
  27. */
  28. public function logout()
  29. {
  30. return $this->redirectToRoute('app_login');
  31. }
  32. }