本文整理匯總了PHP中Sentinel::hasAccess方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sentinel::hasAccess方法的具體用法?PHP Sentinel::hasAccess怎麽用?PHP Sentinel::hasAccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sentinel
的用法示例。
在下文中一共展示了Sentinel::hasAccess方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: render
public function render()
{
$this->_shareData();
if (!\Sentinel::hasAccess($this->permissions['view'])) {
return view('eztool::no_permission');
}
return view('eztool::permission_editor.render');
}
示例2: 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);
}
示例3: aclSentinel
/**
* 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);
}
示例4: function
| 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.
|
示例5: function
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');
}
示例6: hasPermission
/**
* @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;
}