Conditions | 4 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 4.3731 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
16 | 47 | public function handle($request, Closure $next) |
|
17 | { |
||
18 | 47 | $user = \Auth::user(); |
|
19 | |||
20 | // If user is not logged |
||
21 | 47 | if (! $user) { |
|
22 | return redirect('/')->with('message', 'You have not admin access'); |
||
23 | } |
||
24 | |||
25 | // If user is logged and admin/superadmin |
||
26 | //if (($user->isAdmin() || $user->isSuperAdmin()) == 1) { |
||
27 | 47 | if (($user->group == 2) || ($user->group == 1)) { |
|
|
|||
28 | 47 | return $next($request); |
|
29 | } |
||
30 | |||
31 | // Return to homepage if user il logged but not admin |
||
32 | return redirect('/')->with('message', 'You have not admin access'); |
||
33 | } |
||
35 |