1919use Laravel \Passport \ClientRepository ;
2020use Laravel \Passport \Passport ;
2121use Laravel \Passport \PassportUserProvider ;
22- use Laravel \Passport \TokenRepository ;
2322use Laravel \Passport \TransientToken ;
2423use League \OAuth2 \Server \Exception \OAuthServerException ;
2524use League \OAuth2 \Server \ResourceServer ;
@@ -44,13 +43,6 @@ class TokenGuard implements Guard
4443 */
4544 protected $ provider ;
4645
47- /**
48- * The token repository instance.
49- *
50- * @var \Laravel\Passport\TokenRepository
51- */
52- protected $ tokens ;
53-
5446 /**
5547 * The client repository instance.
5648 *
@@ -84,7 +76,6 @@ class TokenGuard implements Guard
8476 *
8577 * @param \League\OAuth2\Server\ResourceServer $server
8678 * @param \Laravel\Passport\PassportUserProvider $provider
87- * @param \Laravel\Passport\TokenRepository $tokens
8879 * @param \Laravel\Passport\ClientRepository $clients
8980 * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
9081 * @param \Illuminate\Http\Request $request
@@ -93,13 +84,11 @@ class TokenGuard implements Guard
9384 public function __construct (
9485 ResourceServer $ server ,
9586 PassportUserProvider $ provider ,
96- TokenRepository $ tokens ,
9787 ClientRepository $ clients ,
9888 Encrypter $ encrypter ,
9989 Request $ request
10090 ) {
10191 $ this ->server = $ server ;
102- $ this ->tokens = $ tokens ;
10392 $ this ->clients = $ clients ;
10493 $ this ->provider = $ provider ;
10594 $ this ->encrypter = $ encrypter ;
@@ -109,7 +98,7 @@ public function __construct(
10998 /**
11099 * Get the user for the incoming request.
111100 *
112- * @return mixed
101+ * @return \Illuminate\Contracts\Auth\Authenticatable|null
113102 */
114103 public function user ()
115104 {
@@ -135,7 +124,6 @@ public function validate(array $credentials = [])
135124 return ! is_null ((new static (
136125 $ this ->server ,
137126 $ this ->provider ,
138- $ this ->tokens ,
139127 $ this ->clients ,
140128 $ this ->encrypter ,
141129 $ credentials ['request ' ],
@@ -172,7 +160,7 @@ public function client()
172160 * Authenticate the incoming request via the Bearer token.
173161 *
174162 * @param \Illuminate\Http\Request $request
175- * @return mixed
163+ * @return \Illuminate\Contracts\Auth\Authenticatable|null
176164 */
177165 protected function authenticateViaBearerToken ($ request )
178166 {
@@ -190,6 +178,8 @@ protected function authenticateViaBearerToken($request)
190178 return ;
191179 }
192180
181+ $ this ->setClient ($ client );
182+
193183 // If the access token is valid we will retrieve the user according to the user ID
194184 // associated with the token. We will use the provider implementation which may
195185 // be used to retrieve users from Eloquent. Next, we'll be ready to continue.
@@ -206,7 +196,7 @@ protected function authenticateViaBearerToken($request)
206196 // authorization such as within the developer's Laravel model policy classes.
207197 $ token = AccessToken::fromPsrRequest ($ psr );
208198
209- return $ token ? $ user ->withAccessToken ($ token ) : null ;
199+ return $ user ->withAccessToken ($ token );
210200 }
211201
212202 /**
@@ -242,7 +232,7 @@ protected function getPsrRequestViaBearerToken($request)
242232 * Authenticate the incoming request via the token cookie.
243233 *
244234 * @param \Illuminate\Http\Request $request
245- * @return mixed
235+ * @return \Illuminate\Contracts\Auth\Authenticatable|null
246236 */
247237 protected function authenticateViaCookie ($ request )
248238 {
@@ -262,7 +252,7 @@ protected function authenticateViaCookie($request)
262252 * Get the token cookie via the incoming request.
263253 *
264254 * @param \Illuminate\Http\Request $request
265- * @return mixed
255+ * @return array|null
266256 */
267257 protected function getTokenViaCookie ($ request )
268258 {
0 commit comments