GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Authenticate   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 49
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 9 2
A terminate() 0 5 1
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use Auth;
6
use Closure;
7
use Illuminate\Contracts\Auth\Guard;
8
use Illuminate\Http\Request;
9
use Illuminate\Support\Facades\Log;
10
use Illuminate\Support\Facades\Route;
11
12
class Authenticate
13
{
14
    /**
15
     * The Guard implementation.
16
     *
17
     * @var Guard
18
     */
19
    protected $auth;
20
21
    /**
22
     * Create a new filter instance.
23
     *
24
     * @param Guard $auth
25
     *
26
     * @return void
27
     */
28
    public function __construct(Guard $auth)
29
    {
30
        $this->auth = $auth;
31
    }
32
33
    /**
34
     * Handle an incoming request.
35
     *
36
     * @param \Illuminate\Http\Request $request
37
     * @param \Closure                 $next
38
     *
39
     * ////////////////
40
     * @param $role
41
     * ////////////////
42
     *
43
     * @return mixed
44
     */
45
    public function handle($request, Closure $next, $role)
0 ignored issues
show
Unused Code introduced by
The parameter $role is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

45
    public function handle($request, Closure $next, /** @scrutinizer ignore-unused */ $role)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
46
    {
47
        if (!$this->auth->check()) {
48
            return redirect()->to('/login')
49
                ->with('status', 'success')
50
                ->with('message', 'Please login.');
51
        }
52
53
        return $next($request);
54
    }
55
56
    public function terminate($request, $response)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

56
    public function terminate(/** @scrutinizer ignore-unused */ $request, $response)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $response is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

56
    public function terminate($request, /** @scrutinizer ignore-unused */ $response)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
57
    {
58
        $user = Auth::user();
59
        $currentRoute = Route::currentRouteName();
60
        Log::info('Authenticate middlware was used: '.$currentRoute.'. ', [$user]);
61
    }
62
}
63