Completed
Push — master ( 96e036...eed5cf )
by Ben
02:47
created

Developer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 10 3
1
<?php
2
3
namespace Thinktomorrow\Squanto\Manager\Http\Middleware;
4
5
use App\User;
6
use Closure;
7
use Illuminate\Support\Facades\Auth;
8
9
class Developer
10
{
11
    /**
12
     * Restrict access for developers only.
13
     *
14
     * This is a very simplistic and modest approach to shielding off these routes
15
     * so for your production projects you should setup your own permissions logic instead.
16
     *
17
     * @param  \Illuminate\Http\Request  $request
18
     * @param  \Closure  $next
19
     * @param  string|null  $guard
20
     * @return mixed
21
     */
22
    public function handle($request, Closure $next, $guard = null)
23
    {
24
        $loggedUser = Auth::guard($guard)->user();
25
26
        if (!$loggedUser || ! $loggedUser->isSquantoDeveloper()) {
27
            return redirect('/');
28
        }
29
30
        return $next($request);
31
    }
32
}
33