@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | $this->secret = $this->getDefaults()['config']['MASTER_KEY']; |
| 101 | 101 | |
| 102 | - if( isset($options['secret']) && $options['secret'] == 'append' ) { |
|
| 102 | + if (isset($options['secret']) && $options['secret'] == 'append') { |
|
| 103 | 103 | $this->secretAppend = true; |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | \PDO::FETCH_OBJ |
| 139 | 139 | ); |
| 140 | 140 | |
| 141 | - if( $this->secretAppend ) { |
|
| 141 | + if ($this->secretAppend) { |
|
| 142 | 142 | $this->secret = $account->secret; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $account->refresh_token = $this->refreshTokenGenerate($account); |
| 152 | 152 | $sentToken = (new headers\header)->hasBearerToken(); |
| 153 | 153 | |
| 154 | - if( $sentToken ) { |
|
| 154 | + if ($sentToken) { |
|
| 155 | 155 | /** |
| 156 | 156 | * [$jwt Decode the JWT] |
| 157 | 157 | * @var auth\jwt |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | ; |
| 170 | 170 | $absSeconds = ($decoded['exp'] - ($this->timeNow() - $leeway)); |
| 171 | 171 | |
| 172 | - if( $absSeconds > 0 ) { |
|
| 172 | + if ($absSeconds > 0) { |
|
| 173 | 173 | $account->JWT = $sentToken; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -207,21 +207,21 @@ discard block |
||
| 207 | 207 | public function refreshTokenGenerate($account) |
| 208 | 208 | { |
| 209 | 209 | $offset = 86400; |
| 210 | - $time = ($this->timeNow()+$offset); |
|
| 210 | + $time = ($this->timeNow() + $offset); |
|
| 211 | 211 | |
| 212 | - if( isset($account->refresh_token) && !empty($account->refresh_token) ) { |
|
| 212 | + if (isset($account->refresh_token) && !empty($account->refresh_token)) { |
|
| 213 | 213 | $raToken = explode('.', $account->refresh_token); |
| 214 | - if( !empty($raToken) ) { |
|
| 214 | + if (!empty($raToken)) { |
|
| 215 | 215 | $raToken = array_values(array_filter($raToken)); |
| 216 | - $time = ($raToken[0] <= ($this->timeNow()-$offset) ) ? ($this->timeNow()+$offset) : $raToken[0]; |
|
| 216 | + $time = ($raToken[0] <= ($this->timeNow() - $offset)) ? ($this->timeNow() + $offset) : $raToken[0]; |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | $cipher = new encoder\cipher; |
| 221 | - $refreshHash = $account->account_id.':'.$account->secret; |
|
| 221 | + $refreshHash = $account->account_id . ':' . $account->secret; |
|
| 222 | 222 | $refreshHash = $cipher->encode($cipher->hash('sha256', $refreshHash, $account->secret)); |
| 223 | 223 | |
| 224 | - $refreshHash = $time.'.'.$refreshHash; |
|
| 224 | + $refreshHash = $time . '.' . $refreshHash; |
|
| 225 | 225 | $account->refreshToken = $refreshHash; |
| 226 | 226 | |
| 227 | 227 | $updateProp = [ |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | /** |
| 294 | 294 | * Check token expiry |
| 295 | 295 | */ |
| 296 | - if($this->checkVal($userPayload['payload'], 'exp') && !$skipExpiry) { |
|
| 296 | + if ($this->checkVal($userPayload['payload'], 'exp') && !$skipExpiry) { |
|
| 297 | 297 | return $this->refreshJWT($userPayload); |
| 298 | 298 | } |
| 299 | 299 | |
@@ -357,26 +357,26 @@ discard block |
||
| 357 | 357 | $payload['iat'] = $iat; |
| 358 | 358 | } |
| 359 | 359 | if (false !== ($nbf = $this->checkVal($jwtOptions, 'notBeFor'))) { |
| 360 | - if( strtolower($nbf) == 'issuedat' && isset($payload['iat']) ) { |
|
| 360 | + if (strtolower($nbf) == 'issuedat' && isset($payload['iat'])) { |
|
| 361 | 361 | $nbf = $payload['iat'] + 10; |
| 362 | 362 | } |
| 363 | 363 | $payload['nbf'] = $nbf; |
| 364 | 364 | } |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - if( $refresh && $exp ) { |
|
| 367 | + if ($refresh && $exp) { |
|
| 368 | 368 | $refreshPayload = $payload; |
| 369 | 369 | |
| 370 | 370 | $offset = $exp - $this->timeNow(); |
| 371 | 371 | $leeway = ($this->checkVal($this->options['jwt'], 'leeway')) ?: $this->jwt->getLeeway(); |
| 372 | 372 | |
| 373 | - $refreshPayload['exp'] = $exp+$offset+$leeway; |
|
| 373 | + $refreshPayload['exp'] = $exp + $offset + $leeway; |
|
| 374 | 374 | |
| 375 | 375 | $refreshJWT = $this->refreshJWT([ |
| 376 | 376 | 'payload' => $refreshPayload |
| 377 | 377 | ]); |
| 378 | 378 | |
| 379 | - if( isset($refreshJWT['refresh']) ) { |
|
| 379 | + if (isset($refreshJWT['refresh'])) { |
|
| 380 | 380 | return $refreshJWT['refresh']; |
| 381 | 381 | } |
| 382 | 382 | } |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | ->decode() |
| 53 | 53 | ; |
| 54 | 54 | |
| 55 | - $this->assertEquals(true, (is_array($decoded)&&!empty($decoded)) ); |
|
| 55 | + $this->assertEquals(true, (is_array($decoded) && !empty($decoded))); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | 'MESSAGE' => $message, |
| 171 | 171 | ), JSON_PRETTY_PRINT); |
| 172 | 172 | |
| 173 | - if( isset($options['errors']) && $options['errors'] == 'catchAll' ) { |
|
| 173 | + if (isset($options['errors']) && $options['errors'] == 'catchAll') { |
|
| 174 | 174 | throw new self($eMessage, 1); |
| 175 | 175 | } |
| 176 | 176 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | 'MESSAGE' => $message, |
| 186 | 186 | ), JSON_PRETTY_PRINT); |
| 187 | 187 | |
| 188 | - if( isset($options['errors']) && $options['errors'] == 'catchAll' ) { |
|
| 188 | + if (isset($options['errors']) && $options['errors'] == 'catchAll') { |
|
| 189 | 189 | throw new self($eMessage, 1); |
| 190 | 190 | } |
| 191 | 191 | |