fix: 用户权限认证
This commit is contained in:
parent
2d61786ec6
commit
cbb3c156a6
@ -63,18 +63,14 @@ trait UserRelations
|
||||
$permissions = $permissionsModel->get();
|
||||
} else {
|
||||
$permissions = Collection::make();
|
||||
|
||||
app($this->getRolesModel())->with(['permissions'])->get()
|
||||
|
||||
$this->roles()->with('permissions')->get()
|
||||
->each(function ($role) use (&$permissions) {
|
||||
$permissions = $permissions->concat($role->permissions);
|
||||
});
|
||||
|
||||
$permissions = $permissions->unique();
|
||||
}
|
||||
|
||||
$this->setAttribute('permissions', $permissions->each(fn ($permission) => $permission->setAttribute('hidden', $permission->isHidden())));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -103,14 +99,15 @@ trait UserRelations
|
||||
if ($permission->isAction()) {
|
||||
[$controller, $action] = explode('@', $permission->permission_mark);
|
||||
|
||||
$actions->add(CatchAdmin::getModuleControllerNamespace($permission->module).$controller.'Controller@'.$action);
|
||||
$actions->add(CatchAdmin::getModuleControllerNamespace($permission->module). ucfirst($controller).'Controller@'.$action);
|
||||
}
|
||||
});
|
||||
|
||||
// 自定义权限判断
|
||||
if ($permission) {
|
||||
[$module, $controller, $action] = explode('@', $permission);
|
||||
|
||||
$permission = CatchAdmin::getModuleControllerNamespace($module).$controller.'Controller@'.$action;
|
||||
$permission = CatchAdmin::getModuleControllerNamespace($module). ucfirst($controller) .'Controller@'.$action;
|
||||
}
|
||||
|
||||
return $actions->contains($permission ?: Route::currentRouteAction());
|
||||
|
@ -73,7 +73,8 @@ class User extends Model implements AuthenticatableContract
|
||||
protected function DepartmentId(): Attribute
|
||||
{
|
||||
return new Attribute(
|
||||
get: fn($value) => $value ? : null
|
||||
get: fn($value) => $value ? : null,
|
||||
set: fn($value) => $value ? : 0
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user