Skip to content

Commit 8080230

Browse files
committed
bug #8519 Improved the first example of the Guard authenticator (javiereguiluz)
This PR was merged into the 3.4 branch. Discussion ---------- Improved the first example of the Guard authenticator I don't like the changes I made to this example in #8497. I consider that the new version of the example makes more sense and it's more correct. Commits ------- ad84f23 Improved the first example of the Guard authenticator
2 parents 843af05 + ad84f23 commit 8080230

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

security/guard_authentication.rst

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,23 +171,17 @@ This requires you to implement several methods::
171171
*/
172172
public function supports(Request $request)
173173
{
174-
return true;
174+
return $request->headers->has('X-AUTH-TOKEN')
175175
}
176176

177177
/**
178178
* Called on every request. Return whatever credentials you want to
179-
* be passed to getUser().
179+
* be passed to getUser() as $credentials.
180180
*/
181181
public function getCredentials(Request $request)
182182
{
183-
if (!$token = $request->headers->get('X-AUTH-TOKEN')) {
184-
// No token?
185-
$token = null;
186-
}
187-
188-
// What you return here will be passed to getUser() as $credentials
189183
return array(
190-
'token' => $token,
184+
'token' => $request->headers->get('X-AUTH-TOKEN'),
191185
);
192186
}
193187

0 commit comments

Comments
 (0)