Conditions | 4 |
Paths | 5 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 5.024 |
Changes | 0 |
1 | <?php |
||
14 | 33 | public function handle(Request $request, Closure $next) |
|
15 | { |
||
16 | 33 | if (!$token = $this->auth->setRequest($request)->getToken()) { |
|
17 | return $this->respond('tymon.jwt.absent', 'token_not_provided', 401); |
||
18 | } |
||
19 | |||
20 | try { |
||
21 | 33 | $user = $this->auth->authenticate($token); |
|
22 | } catch (TokenInvalidException $exception) { |
||
23 | abort(401, 'Invalid or expired token'); |
||
24 | } |
||
25 | |||
26 | 33 | if (!$user) { |
|
27 | return $this->respond('tymon.jwt.user_not_found', 'user_not_found', 401); |
||
28 | } |
||
29 | |||
30 | 33 | $this->events->dispatch('tymon.jwt.valid', $user); |
|
31 | |||
32 | 33 | return $next($request); |
|
33 | } |
||
35 |