src/Controller/SecurityController.php line 20

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