Passed
Branch master (52330f)
by Md. Julfiker
04:41
created
src/exceptions/CsrfTimeOutException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,4 +7,4 @@
 block discarded – undo
7 7
  * Csrf token timeout exception
8 8
  * @autho: Julfiker <[email protected]>
9 9
  */
10
-class CsrfTimeOutException extends Exception {protected $massage = "Token already expired! please try again.";}
10
+class CsrfTimeOutException extends Exception {protected $massage = "Token already expired! please try again."; }
Please login to merge, or discard this patch.
src/manager/CsrfManager.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     public function generateToken() {
91 91
         $sesId = session_id();
92 92
         if (!$sesId)
93
-           $sesId = session_id("UN_AUTHORIZED");
93
+            $sesId = session_id("UN_AUTHORIZED");
94 94
 
95 95
         $this->CSRFToken = md5($sesId+self::SLAT+time());
96 96
         $minutes = $this->tokenValidInMinutes;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         if (!$this->session->has(self::SESSION_STORE_TOKEN_NAME) || $this->_isTokenExpired())
131 131
         $this->refreshToken();
132 132
 
133
-       return $this->session->get(self::SESSION_STORE_TOKEN_NAME);
133
+        return $this->session->get(self::SESSION_STORE_TOKEN_NAME);
134 134
     }
135 135
 
136 136
     /**
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
     public function checkToken() {
73 73
         $pass = false;
74 74
         $method = $this->request->getRealMethod();
75
-        if (in_array($method, ['PUT','POST','DELETE'])) {
75
+        if (in_array($method, [ 'PUT', 'POST', 'DELETE' ])) {
76 76
             $csrfToken = $this->getRequest()->get($this->getTokenFieldName());
77 77
             if ($csrfToken && $this->getStorageToken() == $csrfToken) {
78 78
                 $pass = true;
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -89,8 +89,9 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function generateToken() {
91 91
         $sesId = session_id();
92
-        if (!$sesId)
93
-           $sesId = session_id("UN_AUTHORIZED");
92
+        if (!$sesId) {
93
+                   $sesId = session_id("UN_AUTHORIZED");
94
+        }
94 95
 
95 96
         $this->CSRFToken = md5($sesId+self::SLAT+time());
96 97
         $minutes = $this->tokenValidInMinutes;
@@ -108,8 +109,9 @@  discard block
 block discarded – undo
108 109
      * @return string
109 110
      */
110 111
     public function getStorageToken() {
111
-        if ($this->session->get(self::SESSION_STORE_TOKEN_NAME) && $this->_isNotExpiredAt())
112
-            return $this->session->get(self::SESSION_STORE_TOKEN_NAME);
112
+        if ($this->session->get(self::SESSION_STORE_TOKEN_NAME) && $this->_isNotExpiredAt()) {
113
+                    return $this->session->get(self::SESSION_STORE_TOKEN_NAME);
114
+        }
113 115
 
114 116
         return false;
115 117
     }
@@ -127,8 +129,9 @@  discard block
 block discarded – undo
127 129
      * @return string
128 130
      */
129 131
     public function getCSRFToken() {
130
-        if (!$this->session->has(self::SESSION_STORE_TOKEN_NAME) || $this->_isTokenExpired())
131
-        $this->refreshToken();
132
+        if (!$this->session->has(self::SESSION_STORE_TOKEN_NAME) || $this->_isTokenExpired()) {
133
+                $this->refreshToken();
134
+        }
132 135
 
133 136
        return $this->session->get(self::SESSION_STORE_TOKEN_NAME);
134 137
     }
Please login to merge, or discard this patch.