Authenticate::redirectTo()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 9
rs 10
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->has('sso')){
18
            session()->put('sso', $request->get('sso'));
19
            session()->put('sig', $request->get('sig'));
20
        }
21
22
        if (! $request->expectsJson()) {
23
            return route('login');
24
        }
25
    }
26
27
    protected function authenticate($request, array $guards)
28
    {
29
        if (empty($guards)) {
30
            $guards = [null];
31
        }
32
        foreach ($guards as $guard) {
33
            if ($this->auth->guard($guard)->check()) {
34
                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...
35
            }
36
            if ($request->input('wiki_session_id') && $request->input('wiki_session_id') !== null) {
37
                return;
38
            }
39
        }
40
        $this->unauthenticated($request, $guards);
41
    }
42
}
43