@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @throws \Psr\Container\ContainerExceptionInterface |
| 22 | 22 | * @throws \Psr\Container\NotFoundExceptionInterface |
| 23 | 23 | */ |
| 24 | - public function createToken($properties = []) |
|
| 24 | + public function createToken($properties = [ ]) |
|
| 25 | 25 | { |
| 26 | 26 | $jwt = new JwtWrapper(Psr11::container()->get('API_SERVER'), Psr11::container()->get('JWT_SECRET')); |
| 27 | 27 | $jwtData = $jwt->createJwtData($properties, 1800); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | try { |
| 41 | 41 | $jwt = new JwtWrapper(Psr11::container()->get('API_SERVER'), Psr11::container()->get('JWT_SECRET')); |
| 42 | 42 | $tokenInfo = json_decode(json_encode($jwt->extractData($token)), true); |
| 43 | - return $tokenInfo['data']; |
|
| 43 | + return $tokenInfo[ 'data' ]; |
|
| 44 | 44 | } catch (\Exception $ex) { |
| 45 | 45 | throw new Error401Exception($ex->getMessage()); |
| 46 | 46 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | public function requireRole($role, $token = null) |
| 58 | 58 | { |
| 59 | 59 | $data = $this->requireAuthenticated($token); |
| 60 | - if ($data['role'] !== $role) { |
|
| 60 | + if ($data[ 'role' ] !== $role) { |
|
| 61 | 61 | throw new Error401Exception('Insufficient privileges - ' . print_r($data, true)); |
| 62 | 62 | } |
| 63 | 63 | return $data; |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | $token = $this->createToken($metadata); |
| 74 | 74 | |
| 75 | 75 | $response->getResponseBag()->serializationRule(ResponseBag::SINGLE_OBJECT); |
| 76 | - $response->write(['token' => $token]); |
|
| 77 | - $response->write(['data' => $metadata]); |
|
| 76 | + $response->write([ 'token' => $token ]); |
|
| 77 | + $response->write([ 'data' => $metadata ]); |
|
| 78 | 78 | } |
| 79 | 79 | } |