fix(backend): 管理者権限のロールを持っていても一部のAPIが使用できないことがある問題を修正

This commit is contained in:
syuilo 2023-10-19 20:47:23 +09:00
parent e5598da7a2
commit 4a7c6e261a
2 changed files with 3 additions and 1 deletions

View file

@ -318,8 +318,9 @@ export class ApiCallService implements OnApplicationShutdown {
}
if (ep.meta.requireRolePolicy != null && !user!.isRoot) {
const myRoles = await this.roleService.getUserRoles(user!.id);
const policies = await this.roleService.getUserPolicies(user!.id);
if (!policies[ep.meta.requireRolePolicy]) {
if (!policies[ep.meta.requireRolePolicy] && !myRoles.some(r => r.isAdministrator)) {
throw new ApiError({
message: 'You are not assigned to a required role.',
code: 'ROLE_PERMISSION_DENIED',