From ad84f23b23dc756c06fc93ccdd4770e8c11bad81 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 17 Oct 2017 12:01:00 +0200 Subject: [PATCH] Improved the first example of the Guard authenticator --- security/guard_authentication.rst | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/security/guard_authentication.rst b/security/guard_authentication.rst index 8567b32541a..05712a1e5ef 100644 --- a/security/guard_authentication.rst +++ b/security/guard_authentication.rst @@ -171,23 +171,17 @@ This requires you to implement several methods:: */ public function supports(Request $request) { - return true; + return $request->headers->has('X-AUTH-TOKEN') } /** * Called on every request. Return whatever credentials you want to - * be passed to getUser(). + * be passed to getUser() as $credentials. */ public function getCredentials(Request $request) { - if (!$token = $request->headers->get('X-AUTH-TOKEN')) { - // No token? - $token = null; - } - - // What you return here will be passed to getUser() as $credentials return array( - 'token' => $token, + 'token' => $request->headers->get('X-AUTH-TOKEN'), ); }