| Conditions | 6 |
| Paths | 13 |
| Total Lines | 29 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 4 | ||
| Bugs | 0 | Features | 2 |
| 1 | <?php |
||
| 46 | public function handle(Request $request, Closure $next, $permissions) |
||
| 47 | { |
||
| 48 | $accessDenied = true; |
||
| 49 | |||
| 50 | if (!$user = $this->auth->getActiveUser()) { |
||
| 51 | Flash::error(trans('dashboard::dashboard.flash.access_denied')); |
||
| 52 | |||
| 53 | return redirect()->back(); |
||
| 54 | } |
||
| 55 | |||
| 56 | if (!is_array($permissions)) { |
||
| 57 | $permissions = [$permissions]; |
||
| 58 | } |
||
| 59 | |||
| 60 | foreach ($permissions as $permission) { |
||
| 61 | |||
| 62 | if ($user->hasAccess($permission)) { |
||
| 63 | $accessDenied = false; |
||
| 64 | } |
||
| 65 | } |
||
| 66 | |||
| 67 | if ($accessDenied) { |
||
| 68 | Flash::error(trans('dashboard::dashboard.flash.access_denied')); |
||
| 69 | |||
| 70 | return redirect()->back(); |
||
| 71 | } |
||
| 72 | |||
| 73 | return $next($request); |
||
| 74 | } |
||
| 75 | } |