@@ -61,8 +61,7 @@ |
||
61 | 61 | * @package Platine\Framework\Auth\Middleware |
62 | 62 | * @template T |
63 | 63 | */ |
64 | -class ApiAuthenticationMiddleware implements MiddlewareInterface |
|
65 | -{ |
|
64 | +class ApiAuthenticationMiddleware implements MiddlewareInterface { |
|
66 | 65 | |
67 | 66 | /** |
68 | 67 | * The Authentication instance |
@@ -67,8 +67,7 @@ |
||
67 | 67 | * @package Platine\Framework\Auth\Authentication |
68 | 68 | * @template T |
69 | 69 | */ |
70 | -class JWTAuthentication implements ApiAuthenticationInterface |
|
71 | -{ |
|
70 | +class JWTAuthentication implements ApiAuthenticationInterface { |
|
72 | 71 | |
73 | 72 | /** |
74 | 73 | * The JWT instance |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | public function getUser(): IdentityInterface |
129 | 129 | { |
130 | 130 | //if (!$this->isLogged()) { |
131 | - // throw new AccountNotFoundException('User not logged', 401); |
|
131 | + // throw new AccountNotFoundException('User not logged', 401); |
|
132 | 132 | //} |
133 | 133 | |
134 | 134 | // $id = $this->session->get('user.id'); |
@@ -223,23 +223,23 @@ discard block |
||
223 | 223 | $expire = $this->config->get('api.auth.expire', 1800); |
224 | 224 | $tokenExpire = time() + $expire; |
225 | 225 | $this->jwt->setSecret($secret) |
226 | - ->setPayload([ |
|
227 | - 'id' => $user->id, |
|
228 | - 'exp' => $tokenExpire, |
|
229 | - ]) |
|
230 | - ->sign(); |
|
226 | + ->setPayload([ |
|
227 | + 'id' => $user->id, |
|
228 | + 'exp' => $tokenExpire, |
|
229 | + ]) |
|
230 | + ->sign(); |
|
231 | 231 | |
232 | 232 | $data = [ |
233 | - 'user' => [ |
|
233 | + 'user' => [ |
|
234 | 234 | 'id' => $user->id, |
235 | 235 | 'username' => $user->username, |
236 | 236 | 'lastname' => $user->lastname, |
237 | 237 | 'firstname' => $user->firstname, |
238 | 238 | 'permissions' => array_unique($permissions), |
239 | - ], |
|
240 | - 'token' => $this->jwt->getToken(), |
|
241 | - //'refresh_token' => '', |
|
242 | - 'expire_at' => $tokenExpire, |
|
239 | + ], |
|
240 | + 'token' => $this->jwt->getToken(), |
|
241 | + //'refresh_token' => '', |
|
242 | + 'expire_at' => $tokenExpire, |
|
243 | 243 | ]; |
244 | 244 | |
245 | 245 | return $data; |
@@ -53,8 +53,7 @@ |
||
53 | 53 | * @class ApiAuthenticationInterface |
54 | 54 | * @package Platine\Framework\Auth |
55 | 55 | */ |
56 | -interface ApiAuthenticationInterface |
|
57 | -{ |
|
56 | +interface ApiAuthenticationInterface { |
|
58 | 57 | |
59 | 58 | /** |
60 | 59 | * Whether the request is authenticated |