1 | <?php |
||
2 | |||
3 | namespace App\Http\Middleware; |
||
4 | |||
5 | use Closure; |
||
6 | use Illuminate\Auth\AuthenticationException; |
||
7 | use Illuminate\Contracts\Auth\Factory as Auth; |
||
8 | |||
9 | class Authenticate |
||
10 | { |
||
11 | /** |
||
12 | * The authentication factory instance. |
||
13 | * |
||
14 | * @var \Illuminate\Contracts\Auth\Factory |
||
15 | */ |
||
16 | protected $auth; |
||
17 | |||
18 | /** |
||
19 | * Create a new middleware instance. |
||
20 | * |
||
21 | * @param \Illuminate\Contracts\Auth\Factory $auth |
||
22 | */ |
||
23 | 47 | public function __construct(Auth $auth) |
|
24 | { |
||
25 | 47 | $this->auth = $auth; |
|
26 | 47 | } |
|
27 | |||
28 | /** |
||
29 | * Handle an incoming request. |
||
30 | * |
||
31 | * @param \Illuminate\Http\Request $request |
||
32 | * @param \Closure $next |
||
33 | * @param string[] ...$guards |
||
34 | * @return mixed |
||
35 | * |
||
36 | * @throws \Illuminate\Auth\AuthenticationException |
||
37 | */ |
||
38 | 46 | public function handle($request, Closure $next, ...$guards) |
|
39 | { |
||
40 | 46 | if ($this->auth->user() != null && $this->auth->user()->verified == 0) { |
|
41 | 1 | auth()->logout(); |
|
42 | 1 | flash()->error(trans('auth.account_not_activated')); |
|
0 ignored issues
–
show
|
|||
43 | 1 | return redirect()->back(); |
|
44 | } |
||
45 | 46 | $this->authenticate($guards); |
|
46 | 43 | return $next($request); |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * Determine if the user is logged in to any of the given guards. |
||
51 | * |
||
52 | * @param array $guards |
||
53 | * @return void |
||
54 | * |
||
55 | * @throws \Illuminate\Auth\AuthenticationException |
||
56 | */ |
||
57 | 46 | protected function authenticate(array $guards) |
|
58 | { |
||
59 | 46 | if (empty($guards)) { |
|
60 | 40 | return $this->auth->authenticate(); |
|
61 | } |
||
62 | |||
63 | 7 | foreach ($guards as $guard) { |
|
64 | 7 | if ($this->auth->guard($guard)->check()) { |
|
65 | 7 | return $this->auth->shouldUse($guard); |
|
0 ignored issues
–
show
Are you sure the usage of
$this->auth->shouldUse($guard) targeting Illuminate\Auth\AuthManager::shouldUse() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
66 | } |
||
67 | } |
||
68 | 1 | throw new AuthenticationException; |
|
69 | } |
||
70 | |||
71 | } |
||
72 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.