本文整理汇总了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;
}