Skip to content

Commit 8ec92f7

Browse files
committed
minor #19142 [Security] [Guard] Improve comment with working example (pasdeloup)
This PR was squashed before being merged into the 2.8 branch (closes #19142). Discussion ---------- [Security] [Guard] Improve comment with working example | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Improve the code given in the comment to make it work. If you follow blindly the previous example (as I did) and never return null, you're stucked in an infinite redirection loop on your login page. Commits ------- b36fc32 [Security] [Guard] Improve comment with working example
2 parents 90151ef + b36fc32 commit 8ec92f7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Symfony/Component/Security/Guard/GuardAuthenticatorInterface.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ interface GuardAuthenticatorInterface extends AuthenticationEntryPointInterface
3939
* Whatever value you return here will be passed to getUser() and checkCredentials()
4040
*
4141
* For example, for a form login, you might:
42-
*
43-
* return array(
44-
* 'username' => $request->request->get('_username'),
45-
* 'password' => $request->request->get('_password'),
46-
* );
42+
*
43+
* if ($request->request->has('_username')) {
44+
* return array(
45+
* 'username' => $request->request->get('_username'),
46+
* 'password' => $request->request->get('_password'),
47+
* );
48+
* } else {
49+
* return;
50+
* }
4751
*
4852
* Or for an API token that's on a header, you might use:
4953
*

0 commit comments

Comments
 (0)