@@ -22,27 +22,27 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | $custom = $this->convertToArray($custom); |
| 24 | 24 | $headers = $request->headers->all(); |
| 25 | - foreach($headers as $key=>$header) |
|
| 26 | - Log::info($key.': '.implode('-',$header)); |
|
| 25 | + foreach ($headers as $key=>$header) |
|
| 26 | + Log::info($key.': '.implode('-', $header)); |
|
| 27 | 27 | |
| 28 | - if($token = $this->auth->setRequest($request)->getToken()) { |
|
| 29 | - }else if ($this->auth->getUserModel()){ |
|
| 28 | + if ($token = $this->auth->setRequest($request)->getToken()) { |
|
| 29 | + } else if ($this->auth->getUserModel()) { |
|
| 30 | 30 | $token = $this->auth->fromUser($this->auth->getUserModel(), $custom); |
| 31 | - }else { |
|
| 31 | + } else { |
|
| 32 | 32 | return $this->respond('tymon.jwt.absent', 'token_not_provided', 401); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | try { |
| 36 | 36 | $user = $this->auth->authenticate($token, $custom); |
| 37 | 37 | } catch (TokenExpiredException $e) { |
| 38 | - return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [$e]); |
|
| 39 | - } catch(InvalidClaimException $e) { |
|
| 40 | - return $this->respond('tymon.jwt.invalid', 'claim_invalid', $e->getStatusCode(), [$e]); |
|
| 38 | + return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [ $e ]); |
|
| 39 | + } catch (InvalidClaimException $e) { |
|
| 40 | + return $this->respond('tymon.jwt.invalid', 'claim_invalid', $e->getStatusCode(), [ $e ]); |
|
| 41 | 41 | } catch (JWTException $e) { |
| 42 | - return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [$e]); |
|
| 42 | + return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [ $e ]); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if (! $user) { |
|
| 45 | + if (!$user) { |
|
| 46 | 46 | return $this->respond('tymon.jwt.user_not_found', 'user_not_found', 404); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | try { |
| 59 | 59 | $newToken = $this->auth->refresh($token, $custom); |
| 60 | 60 | } catch (TokenExpiredException $e) { |
| 61 | - return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [$e]); |
|
| 61 | + return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [ $e ]); |
|
| 62 | 62 | } catch (JWTException $e) { |
| 63 | - return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [$e]); |
|
| 63 | + return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [ $e ]); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // send the refreshed token back to the client |
| 67 | - $response->headers->set('Authorization', 'Bearer ' . $newToken); |
|
| 67 | + $response->headers->set('Authorization', 'Bearer '.$newToken); |
|
| 68 | 68 | |
| 69 | 69 | return $response; |
| 70 | 70 | } |
@@ -22,13 +22,14 @@ |
||
| 22 | 22 | { |
| 23 | 23 | $custom = $this->convertToArray($custom); |
| 24 | 24 | $headers = $request->headers->all(); |
| 25 | - foreach($headers as $key=>$header) |
|
| 26 | - Log::info($key.': '.implode('-',$header)); |
|
| 25 | + foreach($headers as $key=>$header) { |
|
| 26 | + Log::info($key.': '.implode('-',$header)); |
|
| 27 | + } |
|
| 27 | 28 | |
| 28 | 29 | if($token = $this->auth->setRequest($request)->getToken()) { |
| 29 | - }else if ($this->auth->getUserModel()){ |
|
| 30 | + } else if ($this->auth->getUserModel()){ |
|
| 30 | 31 | $token = $this->auth->fromUser($this->auth->getUserModel(), $custom); |
| 31 | - }else { |
|
| 32 | + } else { |
|
| 32 | 33 | return $this->respond('tymon.jwt.absent', 'token_not_provided', 401); |
| 33 | 34 | } |
| 34 | 35 | |