From 597c1074203af56cb39cb742f3f90bf8a95873f4 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Wed, 4 Sep 2024 15:19:15 +0700 Subject: [PATCH] refactor: adjust function --- src/controllers/quotation-controller.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/controllers/quotation-controller.ts b/src/controllers/quotation-controller.ts index 658bae4..8f130c3 100644 --- a/src/controllers/quotation-controller.ts +++ b/src/controllers/quotation-controller.ts @@ -166,10 +166,9 @@ const MANAGE_ROLES = [ "account", ]; -function globalAllow(roles?: string[]) { - return ["system", "head_of_admin", "admin", "branch_manager", "head_of_account"].some((v) => - roles?.includes(v), - ); +function globalAllow(user: RequestWithUser["user"]) { + const allowList = ["system", "head_of_admin", "admin", "branch_manager", "head_of_account"]; + return allowList.some((v) => user.roles?.includes(v)); } @Route("/api/v1/quotation")