Passed
Push — master ( abb268...e8f016 )
by IRFA
03:33
created

ApiLockAccount::handle()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 9
c 0
b 0
f 0
nc 4
nop 2
dl 0
loc 14
rs 9.9666
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 ($request->method() == "POST") {
24
            if (in_array($request->path(), config('irfa.lockout.protected_action_path'))) {
25
                if ($this->lockLogin()) {
26
                    $this->eventFailedLogin();
27
                    $this->logging("API");
28
                    $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...
29
                    $message[config('irfa.lockout.message_name')] = Lang::get('lockoutMessage.locked');
30
                    return response()->json($message);
31
                }
32
            }
33
        }
34
            return $next($request);
35
    }
36
}
37