Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Xbirdfr/47f8c78e23c155f35ef0e9c3c5eae0d3 to your computer and use it in GitHub Desktop.

Select an option

Save Xbirdfr/47f8c78e23c155f35ef0e9c3c5eae0d3 to your computer and use it in GitHub Desktop.
Symfony 5.4 - FormAuthenticator - Remember me Badge
// src\Security\FormAuthenticator.php
// auto generated symfony cli
//edit the file and add ' new RememberMeBadge(), ' into the 'new PasswordCredentials' array
public function authenticate(Request $request): PassportInterface
{
$email = $request->request->get('email', '');
$request->getSession()->set(Security::LAST_USERNAME, $email);
return new Passport(
new UserBadge($email),
new PasswordCredentials($request->request->get('password', '')),
[
new CsrfTokenBadge('authenticate', $request->get('_csrf_token')),
new RememberMeBadge(),
]
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment