Authorisation   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 3
c 2
b 0
f 2
lcom 0
cbo 0
dl 0
loc 36
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 8 2
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use Closure;
6
use Illuminate\Contracts\Auth\Guard;
7
use Illuminate\Support\Facades\Auth;
8
use Illuminate\Support\Facades\Redirect;
9
10
/**
11
 * Class Authorisation.
12
 */
13
class Authorisation
14
{
15
    /**
16
     * The Guard implementation.
17
     *
18
     * @var Guard
19
     */
20
    protected $auth;
21
22
    /**
23
     * Create a new filter instance.
24
     *
25
     * @param Guard $auth
26
     */
27
    public function __construct(Guard $auth)
28
    {
29
        $this->auth = $auth;
30
    }
31
32
    /**
33
     * Handle an incoming request.
34
     *
35
     * @param \Illuminate\Http\Request $request
36
     * @param \Closure                 $next
37
     *
38
     * @return mixed
39
     */
40
    public function handle(\Illuminate\Http\Request $request, Closure $next)
41
    {
42
        if (Auth::user()->cannot('isSuperAdmin', Auth::user())) {
43
            return Redirect::to('auth/login')->with('danger', "Vous n'etes pas authoriser a acéder à cette partie :(");
44
        }
45
46
        return $next($request);
47
    }
48
}
49