Skip to content

Update remember_me.rst #15893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions security/remember_me.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,29 @@ this:
The user will then automatically be logged in on subsequent visits while
the cookie remains valid.

Add the RememberMeBadge() to the Passport
-----------------------------------------
After uncommenting the login template and add some lines in the firewall configuration, the last thing to do is to add a new RememberMeBadge to the Password in the Authenticator.

// src/Security/Authenticator.php
// ...

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->request->get('_csrf_token')),
new RememberMeBadge(),
]
);
}

Forcing the User to Re-Authenticate before Accessing certain Resources
----------------------------------------------------------------------

Expand Down