@@ -101,10 +101,14 @@ public function fromUser(JWTSubject $user)
101101 public function refresh ($ forceForever = false , $ resetClaims = false )
102102 {
103103 $ this ->requireToken ();
104+ $ this ->manager ->setRefreshFlow ();
104105
105- return $ this ->manager ->customClaims ($ this ->getCustomClaims ())
106- ->refresh ($ this ->token , $ forceForever , $ resetClaims )
107- ->get ();
106+ if (!$ user = $ this ->authenticate ()) {
107+ throw new UnauthorizedHttpException ('jwt-auth ' , 'User not found ' );
108+ }
109+ return $ this ->manager ->customClaims ($ this ->getClaimsArray ($ user ))
110+ ->refresh ($ this ->token , $ forceForever , $ resetClaims )
111+ ->get ();
108112 }
109113
110114 /**
@@ -181,7 +185,7 @@ public function getToken()
181185 */
182186 public function parseToken ()
183187 {
184- if (! $ token = $ this ->parser ->parseToken ()) {
188+ if (!$ token = $ this ->parser ->parseToken ()) {
185189 throw new JWTException ('The token could not be parsed from the request ' );
186190 }
187191
@@ -246,7 +250,7 @@ protected function getClaimsArray(JWTSubject $subject)
246250 return array_merge (
247251 $ this ->getClaimsForSubject ($ subject ),
248252 $ subject ->getJWTCustomClaims (), // custom claims from JWTSubject method
249- $ this ->customClaims // custom claims from inline setter
253+ $ this ->customClaims // custom claims from inline setter
250254 );
251255 }
252256
@@ -327,7 +331,7 @@ public function unsetToken()
327331 */
328332 protected function requireToken ()
329333 {
330- if (! $ this ->token ) {
334+ if (!$ this ->token ) {
331335 throw new JWTException ('A token is required ' );
332336 }
333337 }
0 commit comments