Skip to content

Commit ad84f23

Browse files
committed
Improved the first example of the Guard authenticator
1 parent f8ddf1f commit ad84f23

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)