4
0
Fork 0

调整权限判断

master
vine_liutk 2022-08-09 16:40:25 +08:00
parent bdc0e01d83
commit 64f1d000b8
1 changed files with 15 additions and 2 deletions

View File

@ -28,13 +28,26 @@ class Permission
{
$user = Admin::user();
$routeName = $request->route()->getName();
$ability = $routeName;
foreach ([
'store' => 'create',
'update' => 'edit',
] as $k => $v) {
if (preg_match("/(.*\.){$k}$/", $routeName, $matches)) {
$ability = $matches[1].$v;
break;
}
}
if (
! $user
|| ! empty($args)
|| ! config('admin.permission.enable')
|| $this->shouldPassThrough($request)
|| $user->isAdministrator()
|| $this->checkRoutePermission($request)
|| $user->hasPermission($ability)
) {
return $next($request);
}
@ -51,7 +64,7 @@ class Permission
/**
* If the route of current request contains a middleware prefixed with 'admin.permission:',
* then it has a manually set permission middleware, we need to handle it first.
*
* 已废弃
* @param Request $request
* @return bool
*/