Passed
Push — develop ( a53779...6ec925 )
by Septianata
03:33
created

RedirectIfUnactive   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 6
c 1
b 0
f 0
dl 0
loc 21
ccs 0
cts 6
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 11 5
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use Closure;
6
use Illuminate\Http\Request;
7
use Illuminate\Support\Facades\Auth;
8
9
class RedirectIfUnactive
10
{
11
    /**
12
     * Handle an incoming request.
13
     *
14
     * @param  \Illuminate\Http\Request  $request
15
     * @param  \Closure  $next
16
     * @param  string|null  ...$guards
17
     * @return mixed
18
     */
19
    public function handle(Request $request, Closure $next, ...$guards)
20
    {
21
        $guards = empty($guards) ? [null] : $guards;
22
23
        foreach ($guards as $guard) {
24
            if (Auth::guard($guard)->check() && !Auth::user()->is_active) {
0 ignored issues
show
Bug introduced by
Accessing is_active on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
25
                return redirect()->intended(route('verification.success'));
26
            }
27
        }
28
29
        return $next($request);
30
    }
31
}
32