<?php
declare(strict_types = 1);
namespace App\Action;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Responder\TemplateResponder;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class LoginAction extends AbstractAction
{
public const ROUTE = true;
public const ROUTE_NAME = 'app_login';
public function __construct(TemplateResponder $templateResponder)
{
$this->templateResponder = $templateResponder;
}
/**
* @Route("/login", name="app_login")
*/
public function __invoke(
Request $request,
AuthenticationUtils $authenticationUtils
): Response {
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
return $this->templateResponder->__invoke(
'security/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error
]);
}
}