public function render() { $this->_shareData(); if (!\Sentinel::hasAccess($this->permissions['view'])) { return view('eztool::no_permission'); } return view('eztool::permission_editor.render'); }
public function render() { $this->_shareData(); if (!\Sentinel::hasAccess($this->permissions['view'])) { return view('eztool::no_permission'); } $roles = \Sentinel::getRoleRepository()->all(); $permissions = Permission::whereNull('parent')->orderBy('order')->get(); return view('eztool::acl_manager.render')->with('roles', $roles)->with('permission_list', $permissions); }
/** * Using Sentinel Authorization Driver * * @param [string] $permission * @param [null] $arguments None. Sentinel doesn't support arguments * @package Cartalyst\Sentinel * @return boolean */ protected function aclSentinel($permission, $arguments = NULL) { return \Sentinel::hasAccess($permission); }
| The following filters are used to verify that the user of the current | session is logged into this application. The "basic" filter easily | integrates HTTP Basic authentication for quick, simple checking. | */ Route::filter('auth', function () { if (Auth::guest()) { if (Request::ajax()) { return Response::make('Unauthorized', 401); } else { return Redirect::guest('login'); } } }); Route::filter('auth.admin', function () { if (Sentinel::check() && !Sentinel::hasAccess('admin')) { return Redirect::to('account')->withErrors(['Only admins can access this page.']); } }); Route::filter('auth.basic', function () { return Auth::basic(); }); /* |-------------------------------------------------------------------------- | Guest Filter |-------------------------------------------------------------------------- | | The "guest" filter is the counterpart of the authentication filters as | it simply checks that the current user is not logged in. A redirect | response will be issued if they are, which you may freely change. |
if (Sentinel::guest()) { if (Request::ajax()) { return Response::make('Unauthorized', 401); } else { return Redirect::guest('login'); } } }); Route::filter('auth.admin', function () { if (\App::environment() != 'service' && \App::environment() != 'local') { return App::abort(401); } if (!Sentinel::check()) { return Redirect::to('admin-login'); } if (!Sentinel::hasAccess('admin')) { return Redirect::to('admin-login')->withErrors(['Admin access required.']); } }); Route::filter('auth.basic', function () { return Auth::basic(); }); /* * Check that the user has one of the permission given */ Route::filter('has_perm', function () { $permissions = array_slice(func_get_args(), 2); $authMgr = App::make('Giftertipster\\Service\\Auth\\AuthMgrInterface'); if (!$authMgr->hasPermission($permissions)) { return Redirect::to('/login'); }
/** * @param string|array $hackRoute * @return boolean */ function hasPermission($hackRoute) { if (is_array($hackRoute)) { foreach ($hackRoute as $route) { if (hasPermission($route)) { return true; } } return false; } $prefixes = ['admin', 'api']; $route = hackToRoute($hackRoute); $routePrefix = explode('.', $route)[0]; if (!in_array($routePrefix, $prefixes) || Route::has($route) && (!is_null(\Sentinel::getUser()) && (\Sentinel::getUser()->is_super_admin || \Sentinel::hasAccess($hackRoute)))) { return true; } return false; }