Answer the question
In order to leave comments, you need to log in
Symfony 3.4. How to generate a token when authenticating a user?
I did the authorization according to the documentation, everything works, but I need to generate a token in the database every time I log in.
Actually action:
/**
* @Route("/login", name="login")
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function loginAction(Request $request)
{
$authenticationUtils = $this->get('security.authentication_utils');
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('@User/security/login.html.twig', array(
'last_username' => $lastUsername,
'error' => $error,
));
}
The security system intercepts the request, validates the provided user credentials, authenticates the user if they are correct, and sends the user back to the registration form if they are not.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question