Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd36b949

Browse files
caliendojulienwouterj
authored andcommitted
Update remember_me.rst
Add some line to the Authenticator to add a RememberMeBadge to the Passport returned
1 parent09b9115 commitd36b949

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

‎security/remember_me.rst‎

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

170+
Add the RememberMeBadge() to the Passport
171+
-----------------------------------------
172+
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.
173+
174+
// src/Security/Authenticator.php
175+
// ...
176+
177+
public function authenticate(Request $request): PassportInterface
178+
{
179+
$email = $request->request->get('email', '');
180+
181+
$request->getSession()->set(Security::LAST_USERNAME, $email);
182+
183+
return new Passport(
184+
new UserBadge($email),
185+
new PasswordCredentials($request->request->get('password', '')),
186+
[
187+
new CsrfTokenBadge('authenticate', $request->request->get('_csrf_token')),
188+
new RememberMeBadge(),
189+
]
190+
);
191+
}
192+
170193
Forcing the User to Re-Authenticate before Accessing certain Resources
171194
----------------------------------------------------------------------
172195

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp