本文整理汇总了PHP中Sentry::hasAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::hasAccess方法的具体用法?PHP Sentry::hasAccess怎么用?PHP Sentry::hasAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentry
的用法示例。
在下文中一共展示了Sentry::hasAccess方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* 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);
}
示例2: switch
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'));
}
}
});
示例3: downloadtemplate
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.");
}
}
}
}
}
示例4: switch
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'));
}
}
});