fix: 用户权限认证
This commit is contained in:
parent
2d61786ec6
commit
cbb3c156a6
@ -63,18 +63,14 @@ trait UserRelations
|
|||||||
$permissions = $permissionsModel->get();
|
$permissions = $permissionsModel->get();
|
||||||
} else {
|
} else {
|
||||||
$permissions = Collection::make();
|
$permissions = Collection::make();
|
||||||
|
$this->roles()->with('permissions')->get()
|
||||||
app($this->getRolesModel())->with(['permissions'])->get()
|
|
||||||
|
|
||||||
->each(function ($role) use (&$permissions) {
|
->each(function ($role) use (&$permissions) {
|
||||||
$permissions = $permissions->concat($role->permissions);
|
$permissions = $permissions->concat($role->permissions);
|
||||||
});
|
});
|
||||||
|
|
||||||
$permissions = $permissions->unique();
|
$permissions = $permissions->unique();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setAttribute('permissions', $permissions->each(fn ($permission) => $permission->setAttribute('hidden', $permission->isHidden())));
|
$this->setAttribute('permissions', $permissions->each(fn ($permission) => $permission->setAttribute('hidden', $permission->isHidden())));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,14 +99,15 @@ trait UserRelations
|
|||||||
if ($permission->isAction()) {
|
if ($permission->isAction()) {
|
||||||
[$controller, $action] = explode('@', $permission->permission_mark);
|
[$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) {
|
if ($permission) {
|
||||||
[$module, $controller, $action] = explode('@', $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());
|
return $actions->contains($permission ?: Route::currentRouteAction());
|
||||||
|
@ -73,7 +73,8 @@ class User extends Model implements AuthenticatableContract
|
|||||||
protected function DepartmentId(): Attribute
|
protected function DepartmentId(): Attribute
|
||||||
{
|
{
|
||||||
return new 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