В Symfony 5, официальной документации описан способ создания формы входа в систему.
На контроллере безопасности запрос метода входа для последнего введенного пользователя осуществляется через getLastUsername
метод:
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class SecurityController extends AbstractController
{
public function login(AuthenticationUtils $authenticationUtils): Response
{
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('security/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error,
]);
}
}
Это не работает. При входе в систему, выходе из системы и повторном go на странице входа в систему lastusername
не перехватывается. Как решить эту проблему?