Passed
Push — master ( 86ad47...367093 )
by IRFA
03:54
created
src/Middleware/ApiLockAccount.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
     public function handle($request, Closure $next)
22 22
     {
23 23
         if($this->exceptAccount()){
24
-             return $next($request);
24
+                return $next($request);
25 25
         }
26 26
         
27 27
         if ($request->method() == "POST") {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
      */
21 21
     public function handle($request, Closure $next)
22 22
     {
23
-        if($this->exceptAccount()){
23
+        if ($this->exceptAccount()) {
24 24
              return $next($request);
25 25
         }
26 26
         
Please login to merge, or discard this patch.
src/Middleware/LockAccount.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     public function handle($request, Closure $next)
24 24
     {
25 25
         if($this->exceptAccount()){
26
-             return $next($request);
26
+                return $next($request);
27 27
         } else{
28 28
         if ($request->method() == "POST") {
29 29
             if (in_array($request->path(), config('irfa.lockout.protected_action_path'))) {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@
 block discarded – undo
22 22
      */
23 23
     public function handle($request, Closure $next)
24 24
     {
25
-        if($this->exceptAccount()){
25
+        if ($this->exceptAccount()) {
26 26
              return $next($request);
27
-        } else{
27
+        } else {
28 28
         if ($request->method() == "POST") {
29 29
             if (in_array($request->path(), config('irfa.lockout.protected_action_path'))) {
30 30
                 if ($this->lockLogin()) {
Please login to merge, or discard this patch.
src/Initializing/Variable.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -5,35 +5,35 @@
 block discarded – undo
5 5
 
6 6
 class Variable {
7 7
 
8
-		protected $ip;
9
-	    protected $input=null;
10
-	    protected $dir;
11
-	    protected $path;
12
-	    protected $attemps;
13
-	    protected $except_enabled;
14
-	    protected $except_accounts;
15
-	    protected $permission_code;
8
+        protected $ip;
9
+        protected $input=null;
10
+        protected $dir;
11
+        protected $path;
12
+        protected $attemps;
13
+        protected $except_enabled;
14
+        protected $except_accounts;
15
+        protected $permission_code;
16 16
 
17
-	    /**
18
-		 * Initializing variable.
19
-		 *
20
-		 * @return void
21
-		 */
22
-		protected function initVar(){
23
-			// if(!empty(config('irfa.lockout'))){
24
-		        $this->ip = Request::ip();
25
-		        $this->input = Request::input(config('irfa.lockout.input_name'));
26
-		        $this->dir = config('irfa.lockout.lockout_file_path');
27
-		        $this->attemps = config('irfa.lockout.login_attemps');
28
-		        $this->except_enabled = config('irfa.lockout.enable_except_account');
29
-		        $this->except_accounts = config('irfa.lockout.except_account');
30
-		        $this->path = $this->dir.md5($this->input);
31
-		    // }
32
-    	}
17
+        /**
18
+         * Initializing variable.
19
+         *
20
+         * @return void
21
+         */
22
+        protected function initVar(){
23
+            // if(!empty(config('irfa.lockout'))){
24
+                $this->ip = Request::ip();
25
+                $this->input = Request::input(config('irfa.lockout.input_name'));
26
+                $this->dir = config('irfa.lockout.lockout_file_path');
27
+                $this->attemps = config('irfa.lockout.login_attemps');
28
+                $this->except_enabled = config('irfa.lockout.enable_except_account');
29
+                $this->except_accounts = config('irfa.lockout.except_account');
30
+                $this->path = $this->dir.md5($this->input);
31
+            // }
32
+        }
33 33
 
34
-    	protected function setPath($username){
35
-    		$this->path = $this->dir.md5($username);
36
-    		$this->input = $username;
37
-    	}
34
+        protected function setPath($username){
35
+            $this->path = $this->dir.md5($username);
36
+            $this->input = $username;
37
+        }
38 38
 	
39
-	}
40 39
\ No newline at end of file
40
+    }
41 41
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 class Variable {
7 7
 
8 8
 		protected $ip;
9
-	    protected $input=null;
9
+	    protected $input = null;
10 10
 	    protected $dir;
11 11
 	    protected $path;
12 12
 	    protected $attemps;
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 		 *
20 20
 		 * @return void
21 21
 		 */
22
-		protected function initVar(){
22
+		protected function initVar() {
23 23
 			// if(!empty(config('irfa.lockout'))){
24 24
 		        $this->ip = Request::ip();
25 25
 		        $this->input = Request::input(config('irfa.lockout.input_name'));
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 		    // }
32 32
     	}
33 33
 
34
-    	protected function setPath($username){
34
+    	protected function setPath($username) {
35 35
     		$this->path = $this->dir.md5($username);
36 36
     		$this->input = $username;
37 37
     	}
Please login to merge, or discard this patch.
src/Func/Core.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
     protected function exceptAccount(){
18 18
         $this->initVar();
19 19
         if($this->except_enabled){
20
-          if(in_array($this->input, $this->except_accounts)){
20
+            if(in_array($this->input, $this->except_accounts)){
21 21
             return true;
22
-          } else{
22
+            } else{
23 23
             return false;
24
-          }
24
+            }
25 25
         } else{
26
-         return false;
26
+            return false;
27 27
         }
28 28
     }
29 29
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @return void
75 75
      */
76 76
     protected function eventCleanLockoutAccount() {
77
-       $this->initVar();
77
+        $this->initVar();
78 78
         $this->unlock_account($this->input);
79 79
           
80 80
     }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
      * @return boolean
134 134
      */
135 135
     protected function lockLogin($username = null){
136
-         $this->initVar();
136
+            $this->initVar();
137 137
         if(php_sapi_name() == "cli" AND $username != null){
138 138
             $this->setPath($username);
139 139
         }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
          * @return boolean
162 162
          */
163 163
     private function checkIp($ip_list,$ip){
164
-       $this->initVar();
164
+        $this->initVar();
165 165
         if(collect($ip_list)->contains($ip)){
166 166
             return true;
167 167
         } else{
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
          * @return boolean
177 177
          */
178 178
     public function clear_all(){
179
-       $this->initVar();
179
+        $this->initVar();
180 180
         $file = new Filesystem();
181 181
         if($file->cleanDirectory($this->path)){
182 182
         return true;
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
      *
15 15
      * @return boolean
16 16
      */
17
-    protected function exceptAccount(){
17
+    protected function exceptAccount() {
18 18
         $this->initVar();
19
-        if($this->except_enabled){
20
-          if(in_array($this->input, $this->except_accounts)){
19
+        if ($this->except_enabled) {
20
+          if (in_array($this->input, $this->except_accounts)) {
21 21
             return true;
22
-          } else{
22
+          } else {
23 23
             return false;
24 24
           }
25
-        } else{
25
+        } else {
26 26
          return false;
27 27
         }
28 28
     }
@@ -33,36 +33,36 @@  discard block
 block discarded – undo
33 33
      * @param string $username
34 34
      * @return void
35 35
      */
36
-    protected function eventFailedLogin($username=null){
36
+    protected function eventFailedLogin($username = null) {
37 37
         $this->initVar();
38
-        if($username !== null){
38
+        if ($username !== null) {
39 39
             $this->setPath($username);
40 40
         }
41
-        if(!File::exists($this->dir)){
41
+        if (!File::exists($this->dir)) {
42 42
                 File::makeDirectory($this->dir, 0755, true);
43 43
         }
44 44
 
45
-        if(!File::exists($this->path))
45
+        if (!File::exists($this->path))
46 46
         {
47 47
             $login_fail = 1;
48
-        } else{
48
+        } else {
49 49
 
50 50
             $get = json_decode(File::get($this->path));
51 51
             $ip_list = $get->ip;
52
-            if(!$this->checkIp($ip_list,$this->ip)){
53
-                array_push($ip_list,$this->ip);
52
+            if (!$this->checkIp($ip_list, $this->ip)) {
53
+                array_push($ip_list, $this->ip);
54 54
             }
55
-            if($get->attemps == "lock"){
55
+            if ($get->attemps == "lock") {
56 56
                 $login_fail = "lock";
57
-            } else{
57
+            } else {
58 58
                 $login_fail = $get->attemps+1;
59 59
             }
60 60
         }
61 61
         
62
-            $content = ['username' => $this->input,'attemps' => $login_fail,'ip' => isset($ip_list)?$ip_list:[$this->ip],'last_attemps' => date("Y-m-d H:i:s",time())];
63
-            File::put($this->path,json_encode($content));
64
-            if(File::exists($this->path)){
65
-                chmod($this->path,0755);
62
+            $content = ['username' => $this->input, 'attemps' => $login_fail, 'ip' => isset($ip_list) ? $ip_list : [$this->ip], 'last_attemps' => date("Y-m-d H:i:s", time())];
63
+            File::put($this->path, json_encode($content));
64
+            if (File::exists($this->path)) {
65
+                chmod($this->path, 0755);
66 66
             }
67 67
           
68 68
     }
@@ -98,18 +98,18 @@  discard block
 block discarded – undo
98 98
          * @param  string  $username
99 99
          * @return boolean
100 100
          */
101
-    protected function is_locked($username){
101
+    protected function is_locked($username) {
102 102
         $this->initVar();
103 103
         $this->setPath($username);
104
-        if(File::exists($this->path))
104
+        if (File::exists($this->path))
105 105
         {
106 106
             $get = json_decode(File::get($this->path));
107
-            if($get->attemps > $this->attemps || $get->attemps == "lock"){
107
+            if ($get->attemps > $this->attemps || $get->attemps == "lock") {
108 108
                 return true;
109
-            } else{
109
+            } else {
110 110
                 return false;
111 111
             }
112
-        } else{
112
+        } else {
113 113
             return false;
114 114
         }
115 115
     }
@@ -132,19 +132,19 @@  discard block
 block discarded – undo
132 132
      *
133 133
      * @return boolean
134 134
      */
135
-    protected function lockLogin($username = null){
135
+    protected function lockLogin($username = null) {
136 136
          $this->initVar();
137
-        if(php_sapi_name() == "cli" AND $username != null){
137
+        if (php_sapi_name() == "cli" AND $username != null) {
138 138
             $this->setPath($username);
139 139
         }
140 140
 
141
-        if(File::exists($this->path))
141
+        if (File::exists($this->path))
142 142
         {
143 143
                 $get = json_decode(File::get($this->path));
144
-                if($get->attemps == "lock"){
144
+                if ($get->attemps == "lock") {
145 145
                 return true;
146 146
                 }
147
-                if($get->attemps > $this->attemps){
147
+                if ($get->attemps > $this->attemps) {
148 148
                    
149 149
                     return true;
150 150
                 } else {
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
          *
161 161
          * @return boolean
162 162
          */
163
-    private function checkIp($ip_list,$ip){
163
+    private function checkIp($ip_list, $ip) {
164 164
        $this->initVar();
165
-        if(collect($ip_list)->contains($ip)){
165
+        if (collect($ip_list)->contains($ip)) {
166 166
             return true;
167
-        } else{
167
+        } else {
168 168
             return false;
169 169
         }
170 170
 
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
          *
176 176
          * @return boolean
177 177
          */
178
-    public function clear_all(){
178
+    public function clear_all() {
179 179
        $this->initVar();
180 180
         $file = new Filesystem();
181
-        if($file->cleanDirectory($this->path)){
181
+        if ($file->cleanDirectory($this->path)) {
182 182
         return true;
183
-        } else{
183
+        } else {
184 184
         return false;
185 185
         }
186 186
     }
@@ -191,24 +191,24 @@  discard block
 block discarded – undo
191 191
          * @param string $username
192 192
          * @return mixed
193 193
          */
194
-    public function unlock_account($username){
194
+    public function unlock_account($username) {
195 195
         $this->initVar();
196 196
         $this->setPath($username);
197
-            if(File::exists($this->path)){
197
+            if (File::exists($this->path)) {
198 198
             $readf = File::get($this->path);
199 199
                 File::delete($this->path);
200
-            if(php_sapi_name() == "cli"){
200
+            if (php_sapi_name() == "cli") {
201 201
                 echo Lang::get('lockoutMessage.user_unlock_success')."\n";
202 202
                 return $readf;
203 203
               
204
-            } else{
204
+            } else {
205 205
                 return true;
206 206
             }
207
-        } else{
208
-            if(php_sapi_name() == "cli"){
207
+        } else {
208
+            if (php_sapi_name() == "cli") {
209 209
                 echo Lang::get('lockoutMessage.user_lock_404')."\n";
210 210
                 return false;
211
-            } else{
211
+            } else {
212 212
                 return false;
213 213
             }
214 214
         }
@@ -219,22 +219,22 @@  discard block
 block discarded – undo
219 219
      *
220 220
      * @return mixed
221 221
      */
222
-    public function test_unlock_account($username){
222
+    public function test_unlock_account($username) {
223 223
         $this->initVar();
224 224
         $this->setPath($username);
225
-            if(File::exists($this->path)){
225
+            if (File::exists($this->path)) {
226 226
             $readf = File::get($this->path);
227 227
                 File::delete($this->path);
228
-            if(php_sapi_name() == "cli"){
228
+            if (php_sapi_name() == "cli") {
229 229
                 return true;
230 230
               
231
-            } else{
231
+            } else {
232 232
                 return true;
233 233
             }
234
-        } else{
235
-            if(php_sapi_name() == "cli"){
234
+        } else {
235
+            if (php_sapi_name() == "cli") {
236 236
                 return false;
237
-            } else{
237
+            } else {
238 238
                 return false;
239 239
             }
240 240
         }
@@ -246,23 +246,23 @@  discard block
 block discarded – undo
246 246
      * @param string $username
247 247
      * @return mixed
248 248
      */
249
-    public function check_account($username){
249
+    public function check_account($username) {
250 250
         $this->initVar();
251 251
         $this->setPath($username);
252
-        if(File::exists($this->path)){
252
+        if (File::exists($this->path)) {
253 253
                 $readf = File::get($this->path);
254
-                if(php_sapi_name() == "cli"){
254
+                if (php_sapi_name() == "cli") {
255 255
                 
256 256
                     return $readf;
257 257
                 
258
-                } else{
258
+                } else {
259 259
                     return $readf;
260 260
                 }
261
-            } else{
262
-                if(php_sapi_name() == "cli"){
261
+            } else {
262
+                if (php_sapi_name() == "cli") {
263 263
                     echo Lang::get('lockoutMessage.user_lock_404')."\n";
264 264
                     exit();
265
-                } else{
265
+                } else {
266 266
                     return false;
267 267
                 }
268 268
             }
@@ -274,32 +274,32 @@  discard block
 block discarded – undo
274 274
          * @param string $username
275 275
          * @return mixed
276 276
          */
277
-    public function lock_account($username){
277
+    public function lock_account($username) {
278 278
         $this->initVar();
279
-        $sapi = php_sapi_name() == "cli"?"lock-via-cli":"lock-via-web";
279
+        $sapi = php_sapi_name() == "cli" ? "lock-via-cli" : "lock-via-web";
280 280
         $this->setPath($username);
281
-        try{
282
-            if(!File::exists($this->dir)){
281
+        try {
282
+            if (!File::exists($this->dir)) {
283 283
                 File::makeDirectory($this->dir, 0755, true);
284 284
             }
285 285
                 $login_fail = "lock";
286 286
         
287
-                $content = ['username' => $this->input,'attemps' => $login_fail,'ip' => [$sapi],'last_attemps' => date("Y-m-d H:i:s",time())];
288
-                File::put($this->path,json_encode($content));
289
-                if(File::exists($this->path)){
290
-                chmod($this->path,0755);
287
+                $content = ['username' => $this->input, 'attemps' => $login_fail, 'ip' => [$sapi], 'last_attemps' => date("Y-m-d H:i:s", time())];
288
+                File::put($this->path, json_encode($content));
289
+                if (File::exists($this->path)) {
290
+                chmod($this->path, 0755);
291 291
                 }
292
-                if(php_sapi_name() == "cli"){
292
+                if (php_sapi_name() == "cli") {
293 293
                 return Lang::get('lockoutMessage.user_lock_success')."\n";
294 294
                 
295
-                } else{
295
+                } else {
296 296
                 return true;
297 297
                 }
298
-            } catch(\Exception $e){
299
-                if(php_sapi_name() == "cli"){
298
+            } catch (\Exception $e) {
299
+                if (php_sapi_name() == "cli") {
300 300
                 return "error";
301 301
                 
302
-                } else{
302
+                } else {
303 303
                 return false;
304 304
                 }
305 305
             }
Please login to merge, or discard this patch.
src/Listeners/LockoutAccount.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
         $this->logging();
32 32
         if(!$this->exceptAccount()){
33 33
 
34
-           $this->eventFailedLogin();
34
+            $this->eventFailedLogin();
35 35
            
36 36
         }
37 37
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
     public function handle(Failed $event)
30 30
     {
31 31
         $this->logging();
32
-        if(!$this->exceptAccount()){
32
+        if (!$this->exceptAccount()) {
33 33
 
34 34
            $this->eventFailedLogin();
35 35
            
Please login to merge, or discard this patch.