调整权限判断
parent
bdc0e01d83
commit
64f1d000b8
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue