Completed
Push — master ( 4c9ad8...c78cfd )
by Arnold
02:17
created
src/Jasny/Auth.php 1 patch
Braces   +32 added lines, -10 removed lines patch added patch discarded remove patch
@@ -85,7 +85,9 @@  discard block
 block discarded – undo
85 85
     {
86 86
         $user = static::fetchUserByUsername($username);
87 87
         
88
-        if (!isset($user) || !$user || $user->getPassword() !== static::password($password, $user->getPassword())) return false;
88
+        if (!isset($user) || !$user || $user->getPassword() !== static::password($password, $user->getPassword())) {
89
+         return false;
90
+        }
89 91
         return $user;
90 92
     }
91 93
     
@@ -99,7 +101,9 @@  discard block
 block discarded – undo
99 101
     public static function login($username, $password)
100 102
     {
101 103
         $user = static::verify($username, $password);
102
-        if (!$user) return null;
104
+        if (!$user) {
105
+         return null;
106
+        }
103 107
         
104 108
         return static::setUser($user);
105 109
     }
@@ -112,7 +116,9 @@  discard block
 block discarded – undo
112 116
      */
113 117
     public static function setUser(User $user)
114 118
     {
115
-        if ($user->onLogin() === false) return false;
119
+        if ($user->onLogin() === false) {
120
+         return false;
121
+        }
116 122
         
117 123
         self::$user = $user;
118 124
         static::persistCurrentUser();
@@ -126,7 +132,9 @@  discard block
 block discarded – undo
126 132
     public static function logout()
127 133
     {
128 134
         $user = static::user();
129
-        if (!$user) return;
135
+        if (!$user) {
136
+         return;
137
+        }
130 138
         
131 139
         $user->onLogout();
132 140
         
@@ -143,7 +151,9 @@  discard block
 block discarded – undo
143 151
     {
144 152
         if (!isset(static::$user)) {
145 153
             $uid = static::getCurrentUserId();
146
-            if ($uid) static::$user = static::fetchUserById($uid);
154
+            if ($uid) {
155
+             static::$user = static::fetchUserById($uid);
156
+            }
147 157
         }
148 158
         
149 159
         return static::$user;
@@ -165,8 +175,12 @@  discard block
 block discarded – undo
165 175
      */
166 176
     public static function access($role = null)
167 177
     {
168
-        if (!static::user()) return false;
169
-        if (!isset($role)) return true;
178
+        if (!static::user()) {
179
+         return false;
180
+        }
181
+        if (!isset($role)) {
182
+         return true;
183
+        }
170 184
 
171 185
         return static::user() instanceof Authz\User && static::user()->hasRole($role);
172 186
     }
@@ -179,7 +193,9 @@  discard block
 block discarded – undo
179 193
      */
180 194
     protected static function getSecret()
181 195
     {
182
-        if (!isset(static::$secret)) throw new \Exception("Auth secret isn't set");
196
+        if (!isset(static::$secret)) {
197
+         throw new \Exception("Auth secret isn't set");
198
+        }
183 199
         return static::$secret;
184 200
     }
185 201
     
@@ -206,7 +222,10 @@  discard block
 block discarded – undo
206 222
     public static function fetchForConfirmation($hash)
207 223
     {
208 224
         $id = base_convert(substr($hash, 10), 36, 10);
209
-        if (static::generateConfirmationHash($id) != $hash) return null; // invalid hash
225
+        if (static::generateConfirmationHash($id) != $hash) {
226
+         return null;
227
+        }
228
+        // invalid hash
210 229
         
211 230
         return static::fetchUserById($id);
212 231
     }
@@ -237,7 +256,10 @@  discard block
 block discarded – undo
237 256
         $id = base_convert(substr($hash, 10), 36, 10);
238 257
         
239 258
         $user = static::fetchUserById($id);
240
-        if (!$user || static::generatePasswordResetHash($id, $user->getPassword()) != $hash) return null; // invalid hash
259
+        if (!$user || static::generatePasswordResetHash($id, $user->getPassword()) != $hash) {
260
+         return null;
261
+        }
262
+        // invalid hash
241 263
         
242 264
         return $user;
243 265
     }
Please login to merge, or discard this patch.