Completed
Push — master ( 844878...7c145e )
by claudio
04:10
created
app/Http/Middleware/GetUserAndRefresh.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -22,27 +22,27 @@  discard block
 block discarded – undo
22 22
     {
23 23
         $custom = $this->convertToArray($custom);
24 24
         $headers = $request->headers->all();
25
-        foreach($headers as $key=>$header)
26
-            Log::info($key.': '.implode('-',$header));
25
+        foreach ($headers as $key=>$header)
26
+            Log::info($key.': '.implode('-', $header));
27 27
 
28
-        if($token = $this->auth->setRequest($request)->getToken()) {
29
-        }else if ($this->auth->getUserModel()){
28
+        if ($token = $this->auth->setRequest($request)->getToken()) {
29
+        } else if ($this->auth->getUserModel()) {
30 30
             $token = $this->auth->fromUser($this->auth->getUserModel(), $custom);
31
-        }else {
31
+        } else {
32 32
             return $this->respond('tymon.jwt.absent', 'token_not_provided', 401);
33 33
         }
34 34
 
35 35
         try {
36 36
             $user = $this->auth->authenticate($token, $custom);
37 37
         } catch (TokenExpiredException $e) {
38
-            return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [$e]);
39
-        } catch(InvalidClaimException $e) {
40
-            return $this->respond('tymon.jwt.invalid', 'claim_invalid', $e->getStatusCode(), [$e]);
38
+            return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [ $e ]);
39
+        } catch (InvalidClaimException $e) {
40
+            return $this->respond('tymon.jwt.invalid', 'claim_invalid', $e->getStatusCode(), [ $e ]);
41 41
         } catch (JWTException $e) {
42
-            return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [$e]);
42
+            return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [ $e ]);
43 43
         }
44 44
 
45
-        if (! $user) {
45
+        if (!$user) {
46 46
             return $this->respond('tymon.jwt.user_not_found', 'user_not_found', 404);
47 47
         }
48 48
 
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
         try {
59 59
             $newToken = $this->auth->refresh($token, $custom);
60 60
         } catch (TokenExpiredException $e) {
61
-            return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [$e]);
61
+            return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [ $e ]);
62 62
         } catch (JWTException $e) {
63
-            return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [$e]);
63
+            return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [ $e ]);
64 64
         }
65 65
 
66 66
         // send the refreshed token back to the client
67
-        $response->headers->set('Authorization', 'Bearer ' . $newToken);
67
+        $response->headers->set('Authorization', 'Bearer '.$newToken);
68 68
 
69 69
         return $response;
70 70
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,13 +22,14 @@
 block discarded – undo
22 22
     {
23 23
         $custom = $this->convertToArray($custom);
24 24
         $headers = $request->headers->all();
25
-        foreach($headers as $key=>$header)
26
-            Log::info($key.': '.implode('-',$header));
25
+        foreach($headers as $key=>$header) {
26
+                    Log::info($key.': '.implode('-',$header));
27
+        }
27 28
 
28 29
         if($token = $this->auth->setRequest($request)->getToken()) {
29
-        }else if ($this->auth->getUserModel()){
30
+        } else if ($this->auth->getUserModel()){
30 31
             $token = $this->auth->fromUser($this->auth->getUserModel(), $custom);
31
-        }else {
32
+        } else {
32 33
             return $this->respond('tymon.jwt.absent', 'token_not_provided', 401);
33 34
         }
34 35
 
Please login to merge, or discard this patch.