Conditions | 3 |
Paths | 4 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
11 | public function handle($request, Closure $next, $role) |
||
12 | { |
||
13 | $roles = is_array($role) |
||
14 | ? $role |
||
15 | : explode('|', $role); |
||
16 | $user_roles = array_map('strtolower', Auth::user()->roles); |
||
|
|||
17 | $same = (array_intersect($roles, $user_roles)); |
||
18 | |||
19 | if (empty($same)) { |
||
20 | throw AuthException::auth('401', 'User does not have right roles'); |
||
21 | } |
||
22 | |||
23 | return $next($request); |
||
24 | } |
||
26 |