1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Gewaer\Middleware; |
||
6 | |||
7 | use Gewaer\Http\Request; |
||
8 | use Gewaer\Traits\ResponseTrait; |
||
9 | use Gewaer\Traits\TokenTrait; |
||
10 | use Phalcon\Mvc\Micro\MiddlewareInterface; |
||
11 | use Gewaer\Exception\NotFoundHttpException; |
||
12 | |||
13 | /** |
||
14 | * Class AuthenticationMiddleware. |
||
15 | * |
||
16 | * @package Niden\Middleware |
||
17 | */ |
||
18 | abstract class TokenBase implements MiddlewareInterface |
||
19 | { |
||
20 | use ResponseTrait; |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
21 | use TokenTrait; |
||
22 | |||
23 | /** |
||
24 | * @param Request $request |
||
25 | * |
||
26 | * @return bool |
||
27 | */ |
||
28 | 69 | protected function isValidCheck(Request $request): bool |
|
29 | { |
||
30 | 69 | if (!$request->ignoreJwt() && $request->isEmptyBearerToken()) { |
|
31 | 1 | throw new NotFoundHttpException('Missing Token'); |
|
32 | } |
||
33 | |||
34 | return ( |
||
35 | 68 | true !== $request->ignoreJwt() |
|
36 | ); |
||
37 | } |
||
38 | } |
||
39 |