src/Controller/SecurityController.php line 17

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