Passed
Push — master ( 88e504...69257d )
by Vince
16:59
created
src/core/user/userLoad.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 = [
@@ -356,26 +356,26 @@  discard block
 block discarded – undo
356 356
                 $payload['iat'] = $iat;
357 357
             }
358 358
             if (false !== ($nbf = $this->checkVal($jwtOptions, 'notBeFor'))) {
359
-                if( strtolower($nbf) == 'issuedat' && isset($payload['iat']) ) {
359
+                if (strtolower($nbf) == 'issuedat' && isset($payload['iat'])) {
360 360
                     $nbf = $payload['iat'] + 10;
361 361
                 }
362 362
                 $payload['nbf'] = $nbf;
363 363
             }
364 364
         }
365 365
 
366
-        if( $refresh && $exp ) {
366
+        if ($refresh && $exp) {
367 367
             $refreshPayload = $payload;
368 368
 
369 369
             $offset = $exp - $this->timeNow();
370 370
             $leeway = ($this->checkVal($this->options['jwt'], 'leeway')) ?: $this->jwt->getLeeway();
371 371
 
372
-            $refreshPayload['exp'] = $exp+$offset+$leeway;
372
+            $refreshPayload['exp'] = $exp + $offset + $leeway;
373 373
 
374 374
             $refreshJWT = $this->refreshJWT([
375 375
                 'payload' => $refreshPayload
376 376
             ]);
377 377
 
378
-            if( isset($refreshJWT['refresh']) ) {
378
+            if (isset($refreshJWT['refresh'])) {
379 379
                 return $refreshJWT['refresh'];
380 380
             }
381 381
         }
Please login to merge, or discard this patch.