@@ -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 |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | public function getUser(): IdentityInterface |
140 | 140 | { |
141 | 141 | //if (!$this->isLogged()) { |
142 | - // throw new AccountNotFoundException('User not logged', 401); |
|
142 | + // throw new AccountNotFoundException('User not logged', 401); |
|
143 | 143 | //} |
144 | 144 | |
145 | 145 | // $id = $this->session->get('user.id'); |
@@ -236,11 +236,11 @@ discard block |
||
236 | 236 | $tokenExpire = time() + $expire; |
237 | 237 | $refreshTokenExpire = time() + $refreshExpire; |
238 | 238 | $this->jwt->setSecret($secret) |
239 | - ->setPayload([ |
|
240 | - 'sub' => $user->id, |
|
241 | - 'exp' => $tokenExpire, |
|
242 | - ]) |
|
243 | - ->sign(); |
|
239 | + ->setPayload([ |
|
240 | + 'sub' => $user->id, |
|
241 | + 'exp' => $tokenExpire, |
|
242 | + ]) |
|
243 | + ->sign(); |
|
244 | 244 | $refreshToken = Str::randomToken(24); |
245 | 245 | $jwtToken = $this->jwt->getToken(); |
246 | 246 | |
@@ -254,15 +254,15 @@ discard block |
||
254 | 254 | $this->tokenRepository->save($token); |
255 | 255 | |
256 | 256 | $data = [ |
257 | - 'user' => [ |
|
257 | + 'user' => [ |
|
258 | 258 | 'id' => $user->id, |
259 | 259 | 'username' => $user->username, |
260 | 260 | 'lastname' => $user->lastname, |
261 | 261 | 'firstname' => $user->firstname, |
262 | 262 | 'permissions' => array_unique($permissions), |
263 | - ], |
|
264 | - 'token' => $jwtToken, |
|
265 | - 'refresh_token' => $refreshToken, |
|
263 | + ], |
|
264 | + 'token' => $jwtToken, |
|
265 | + 'refresh_token' => $refreshToken, |
|
266 | 266 | ]; |
267 | 267 | |
268 | 268 | 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 |
@@ -54,8 +54,7 @@ |
||
54 | 54 | * @class Token |
55 | 55 | * @package Platine\Framework\Auth\Entity |
56 | 56 | */ |
57 | -class Token extends Entity |
|
58 | -{ |
|
57 | +class Token extends Entity { |
|
59 | 58 | |
60 | 59 | /** |
61 | 60 | * {@inheritdoc} |
@@ -70,7 +70,7 @@ |
||
70 | 70 | 'updated_at' => '?date', |
71 | 71 | ]); |
72 | 72 | |
73 | - $mapper->filter('not_expire', function (Query $q, $date) { |
|
73 | + $mapper->filter('not_expire', function(Query $q, $date) { |
|
74 | 74 | $q->where('expire_at')->gt($date); |
75 | 75 | }); |
76 | 76 | } |
@@ -55,15 +55,13 @@ |
||
55 | 55 | * @class TokenRepository |
56 | 56 | * @package Platine\Framework\Auth\Repository |
57 | 57 | */ |
58 | -class TokenRepository extends Repository |
|
59 | -{ |
|
58 | +class TokenRepository extends Repository { |
|
60 | 59 | |
61 | 60 | /** |
62 | 61 | * Create new instance |
63 | 62 | * @param EntityManager $manager |
64 | 63 | */ |
65 | - public function __construct(EntityManager $manager) |
|
66 | - { |
|
64 | + public function __construct(EntityManager $manager) { |
|
67 | 65 | parent::__construct($manager, Token::class); |
68 | 66 | } |
69 | 67 | } |