Laravel2step   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 39
c 0
b 0
f 0
rs 10
wmc 9

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 0 27 9
1
<?php
2
3
namespace jeremykenedy\laravel2step\App\Http\Middleware;
4
5
use Closure;
6
use Illuminate\Http\Request;
7
use jeremykenedy\laravel2step\App\Traits\Laravel2StepTrait;
8
9
class Laravel2step
10
{
11
    use Laravel2StepTrait;
0 ignored issues
show
Bug introduced by
The trait jeremykenedy\laravel2ste...raits\Laravel2StepTrait requires the property $id which is not provided by jeremykenedy\laravel2ste...Middleware\Laravel2step.
Loading history...
12
13
    /**
14
     * Handle an incoming request.
15
     *
16
     * @param Request  $request
17
     * @param \Closure $response
18
     *
19
     * @return mixed
20
     */
21
    public function handle($request, Closure $next)
22
    {
23
        $response = $next($request);
24
        $uri = $request->path();
25
        $nextUri = config('app.url').'/'.$uri;
26
27
        switch ($uri) {
28
            case 'verification/needed':
29
            case 'password/reset':
30
            case 'register':
31
            case 'logout':
32
            case 'login':
33
            case '/':
34
                break;
35
36
            default:
37
                session(['nextUri' => $nextUri]);
38
39
                if (config('laravel2step.laravel2stepEnabled')) {
40
                    if ($this->twoStepVerification($request) !== true) {
41
                        return redirect('verification/needed');
42
                    }
43
                }
44
                break;
45
        }
46
47
        return $response;
48
    }
49
}
50