ApiLockAccount::handle()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 11
c 0
b 0
f 0
nc 5
nop 2
dl 0
loc 18
rs 9.6111
1
<?php
2
3
namespace Irfa\Lockout\Middleware;
4
5
use Closure;
6
use Route;
7
use URL;
8
use Lang;
9
use Illuminate\Support\Facades\File;
10
use Irfa\Lockout\Func\Core;
11
12
class ApiLockAccount extends Core
13
{
14
    /**
15
     * Handle an incoming request.
16
     *
17
     * @param  \Illuminate\Http\Request  $request
18
     * @param  \Closure  $next
19
     * @return mixed
20
     */
21
    public function handle($request, Closure $next)
22
    {
23
        if($this->exceptAccount()){
24
             return $next($request);
25
        }
26
        
27
        if ($request->method() == "POST") {
28
            if (in_array($request->path(), config('irfa.lockout.protected_action_path'))) {
29
                if ($this->lockLogin()) {
30
                    $this->eventFailedLogin();
31
                    $this->logging("API");
32
                    $message['code'] = 403;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$message was never initialized. Although not strictly required by PHP, it is generally a good practice to add $message = array(); before regardless.
Loading history...
33
                    $message[config('irfa.lockout.message_name')] = Lang::get('lockoutMessage.locked');
34
                    return response()->json($message);
35
                }
36
            }
37
        }
38
            return $next($request);
39
    }
40
}
41