8000 Added the way to activate remember me in the new authentication system · parijke/symfony-docs@5d49246 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5d49246

Browse files
authored
Added the way to activate remember me in the new authentication system
I had to search a while for myself not understanding why I did not have a REMEMBERME cookie when I activated the new system. So maybe handy to add it.
1 parent 12d52ea commit 5d49246

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

security/remember_me.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,27 @@ this:
167167
The user will then automatically be logged in on subsequent visits while
168168
the cookie remains valid.
169169

170+
Beware that in the new Authenitaction System you have to set the RememberMeBadge()
171+
in the authenticate method of the authenticator, like:
172+
173+
.. code-block:: php
174+
175+
public function authenticate(Request $request): PassportInterface
176+
{
177+
$email = $request->request->get('email', '');
178+
179+
$request->getSession()->set(Security::LAST_USERNAME, $email);
180+
181+
return new Passport(
182+
new UserBadge($email),
183+
new PasswordCredentials($request->request->get('password', '')),
184+
[
185+
new CsrfTokenBadge('authenticate', $request->get('_csrf_token')),
186+
new RememberMeBadge(),
187+
]
188+
);
189+
}
190+
170191
Forcing the User to Re-Authenticate before Accessing certain Resources
171192
----------------------------------------------------------------------
172193

0 commit comments

Comments
 (0)
0