src/Controller/Security/AuthorizationController.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Security;
  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\Core\User\UserInterface;
  7. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  8. class AuthorizationController extends AbstractController
  9. {
  10.     /**
  11.      * @Route("/login", name="app_login")
  12.      *
  13.      * @param AuthenticationUtils $authenticationUtils
  14.      * @return Response
  15.      */
  16.     public function login(AuthenticationUtils $authenticationUtils): Response
  17.     {
  18.          if ($this->getUser() instanceof UserInterface) {
  19.              return $this->redirectToRoute('app_dashboard');
  20.          }
  21.         $error $authenticationUtils->getLastAuthenticationError();
  22.         $lastUsername $authenticationUtils->getLastUsername();
  23.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  24.     }
  25. }