From 9a9692d6d2d75a4a98b05dd0dcf319fc890639b3 Mon Sep 17 00:00:00 2001 From: riku6460 <17585784+riku6460@users.noreply.github.com> Date: Fri, 29 Sep 2023 23:58:27 +0900 Subject: [PATCH] fix typecheck --- packages/backend/src/server/api/ApiCallService.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/api/ApiCallService.ts b/packages/backend/src/server/api/ApiCallService.ts index 8dd0ba494555..809726226851 100644 --- a/packages/backend/src/server/api/ApiCallService.ts +++ b/packages/backend/src/server/api/ApiCallService.ts @@ -321,10 +321,10 @@ export class ApiCallService implements OnApplicationShutdown { if (ep.meta.requireRolePolicy != null && !user!.isRoot) { const policies = await this.roleService.getUserPolicies(user!.id); let denied: boolean; - if (Array.isArray(ep.meta.requireRolePolicy)) { - denied = ep.meta.requireRolePolicy.some(policy => !policies[policy]); - } else { + if (typeof ep.meta.requireRolePolicy === 'string') { denied = !policies[ep.meta.requireRolePolicy]; + } else { + denied = ep.meta.requireRolePolicy.some(policy => !policies[policy]); } if (denied) { throw new ApiError({