| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 3 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 17 | public function handle($request, \Closure $next, $custom = []) |
||
| 18 | { |
||
| 19 | $response = $next($request); |
||
| 20 | |||
| 21 | try { |
||
| 22 | $newToken = $this->auth->setRequest($request)->parseToken()->refresh(false, $custom); |
||
| 23 | } catch (TokenExpiredException $e) { |
||
| 24 | return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [$e]); |
||
| 25 | } catch (JWTException $e) { |
||
| 26 | return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [$e]); |
||
| 27 | } |
||
| 28 | |||
| 29 | // send the refreshed token back to the client |
||
| 30 | $response->headers->set('Authorization', 'Bearer ' . $newToken); |
||
| 31 | |||
| 32 | return $response; |
||
| 33 | } |
||
| 34 | } |
||
| 35 |