src/Action/LoginAction.php line 30

Open in your IDE?
  1. <?php
  2. declare(strict_types 1);
  3. namespace App\Action;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use App\Responder\TemplateResponder;
  8. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  9. class LoginAction extends AbstractAction
  10. {
  11.     public const ROUTE true;
  12.     public const ROUTE_NAME 'app_login';
  13.     public function __construct(TemplateResponder $templateResponder)
  14.     {
  15.         $this->templateResponder $templateResponder;
  16.     }
  17.     /**
  18.      * @Route("/login", name="app_login")
  19.      */
  20.     public function __invoke(
  21.         Request $request,
  22.         AuthenticationUtils $authenticationUtils
  23.     ): Response {
  24.         $error $authenticationUtils->getLastAuthenticationError();
  25.         $lastUsername $authenticationUtils->getLastUsername();
  26.         return $this->templateResponder->__invoke(
  27.             'security/login.html.twig', [
  28.             'last_username' => $lastUsername,
  29.             'error' => $error
  30.         ]);
  31.     }
  32. }