Conditions | 4 |
Paths | 5 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | 7 | public function handle($request, Closure $next, $role) |
|
25 | { |
||
26 | 7 | if (app('auth')->guest()) { |
|
27 | 1 | $helpers = new Helpers(); |
|
28 | 1 | throw new UserNotLoggedIn(403, $helpers->getUserNotLoggedINMessage()); |
|
29 | } |
||
30 | |||
31 | 6 | $roles = \is_array($role) ? $role : \explode('|', $role); |
|
32 | |||
33 | 6 | if (! app('auth')->user()->hasAnyRole($roles)) { |
|
34 | 4 | $helpers = new Helpers(); |
|
35 | 4 | throw new UnauthorizedRole(403, $helpers->getUnauthorizedRoleMessage(implode(', ', $roles)), $roles); |
|
36 | } |
||
37 | |||
38 | 2 | return $next($request); |
|
39 | } |
||
41 |