Completed
Push — master ( 33476c...427ebd )
by Bertrand
09:14
created

Authenticate   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 30
rs 10
c 1
b 0
f 0
wmc 8

2 Methods

Rating   Name   Duplication   Size   Complexity  
A redirectTo() 0 4 2
A authenticate() 0 15 6
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use Illuminate\Auth\Middleware\Authenticate as Middleware;
6
7
class Authenticate extends Middleware
8
{
9
    /**
10
     * Get the path the user should be redirected to when they are not authenticated.
11
     *
12
     * @param  \Illuminate\Http\Request  $request
13
     * @return string|null
14
     */
15
    protected function redirectTo($request)
16
    {
17
        if (! $request->expectsJson()) {
18
            return route('login');
19
        }
20
    }
21
22
    protected function authenticate($request, array $guards)
23
    {
24
        if (empty($guards)) {
25
            $guards = [null];
26
        }
27
28
        foreach ($guards as $guard) {
29
            if ($this->auth->guard($guard)->check()) {
30
                return $this->auth->shouldUse($guard);
0 ignored issues
show
Bug introduced by
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 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.

Loading history...
31
            }
32
            if ($request->input('wiki_session_id') && $request->input('wiki_session_id') !== null) {
33
                return;
34
            }
35
        }
36
        $this->unauthenticated($request, $guards);
37
    }
38
}
39