/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle(Request $request, Closure $next) { if (!\Sentry::check() || !\Sentry::hasAccess('superuser')) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { return redirect()->route('account.login'); } } return $next($request); }
switch ($rule) { case 'index': case 'show': $userRule = $module . '.view'; break; case 'create': case 'store': $userRule = $module . '.create'; break; case 'edit': case 'update': $userRule = $module . '.update'; break; case 'destroy': $userRule = $module . '.delete'; break; default: $userRule = Route::currentRouteName(); break; } } // no access to the request page and request page not the root admin page if (!Sentry::hasAccess($userRule) and $userRule !== 'admin.view') { return Redirect::to('admin')->with('error', Lang::get('backend::permissions.access_denied')); } else { if (!Sentry::hasAccess($userRule) and $userRule === 'admin.view') { //can't see the admin home page go back to home site page return Redirect::to('/')->with('error', Lang::get('backend::permissions.access_denied')); } } });
public function downloadtemplate($data) { $file = public_path() . '/uploads/templates/' . $data; if (file_exists($file)) { return Response::download($file); } else { if (Sentry::hasAccess('admin')) { return Redirect::route('admin.template.index')->with("errorMessage", "Maaf file tidak ada."); } else { if (Sentry::hasAccess('kepala')) { return Redirect::route('admin.template.index')->with("errorMessage", "Maaf file tidak ada."); } else { if (Sentry::hasAccess('kasubbag')) { return Redirect::route('kasubbag.template.index')->with("errorMessage", "Maaf file tidak ada."); } } } } }
switch ($rule) { case 'index': case 'show': $userRule = $module . '.view'; break; case 'create': case 'store': $userRule = $module . '.create'; break; case 'edit': case 'update': $userRule = $module . '.update'; break; case 'destroy': $userRule = $module . '.delete'; break; default: $userRule = Route::currentRouteName(); break; } } // no access to the request page and request page not the root admin page if (!Sentry::hasAccess($userRule) and $userRule !== 'cpanel.view') { return Redirect::route('cpanel.home')->with('error', Lang::get('cpanel::permissions.access_denied')); } else { if (!Sentry::hasAccess($userRule) and $userRule === 'cpanel.view') { //can't see the admin home page go back to home site page return Redirect::to('/')->with('error', Lang::get('cpanel::permissions.access_denied')); } } });