src\Controller\SecurityController.php line 14

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\Security\Core\Security;
  8. class SecurityController extends AbstractController
  9. {
  10. #[Route("/login", "app_security_login")]
  11. public function login(AuthenticationUtils $authenticationUtils): Response
  12. {
  13. if ($this->getUser()) {
  14. return $this->redirectToRoute('homepage');
  15. }
  16. // get the login error if there is one
  17. $error = $authenticationUtils->getLastAuthenticationError();
  18. if ($error) {
  19. $this->addFlash('danger', 'Identifiants invalides');
  20. }
  21. // last username entered by the user
  22. $lastusername = $authenticationUtils->getLastUsername();
  23. return $this->render('security/login.html.twig', ['last_username' => $lastusername]);
  24. }
  25. #[Route("/logout", "app_security_logout")]
  26. public function logout(): void
  27. {
  28. }
  29. }