SentinelUser   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 11 4
1
<?php namespace jlourenco\base\Middleware;
2
3
use Closure;
4
use Sentinel;
5
use Redirect;
6
7
class SentinelUser
8
{
9
    /**
10
     * Handle an incoming request.
11
     *
12
     * @param  \Illuminate\Http\Request  $request
13
     * @param  \Closure  $next
14
     * @return mixed
15
     */
16
    public function handle($request, Closure $next)
17
    {
18
        if (!Sentinel::check() || !Sentinel::inRole('admin')) {
19
            if ($request->ajax()) {
20
                return response('Unauthorized.', 401);
21
            } else {
22
                return Redirect::route('login');
23
            }
24
        }
25
        return $next($request);
26
    }
27
}
28