调整权限判断
parent
bdc0e01d83
commit
64f1d000b8
|
|
@ -28,13 +28,26 @@ class Permission
|
||||||
{
|
{
|
||||||
$user = Admin::user();
|
$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 (
|
if (
|
||||||
! $user
|
! $user
|
||||||
|| ! empty($args)
|
|| ! empty($args)
|
||||||
|| ! config('admin.permission.enable')
|
|| ! config('admin.permission.enable')
|
||||||
|| $this->shouldPassThrough($request)
|
|| $this->shouldPassThrough($request)
|
||||||
|| $user->isAdministrator()
|
|| $user->isAdministrator()
|
||||||
|| $this->checkRoutePermission($request)
|
|| $user->hasPermission($ability)
|
||||||
) {
|
) {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
@ -51,7 +64,7 @@ class Permission
|
||||||
/**
|
/**
|
||||||
* If the route of current request contains a middleware prefixed with 'admin.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.
|
* then it has a manually set permission middleware, we need to handle it first.
|
||||||
*
|
* 已废弃
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue