feat(perm): update api customer/employee perm

This commit is contained in:
Methapon2001 2025-07-02 10:27:24 +07:00
parent adae420ed9
commit 92729fa4af
9 changed files with 54 additions and 39 deletions

View file

@ -23,15 +23,16 @@ const MANAGE_ROLES = [
"system", "system",
"head_of_admin", "head_of_admin",
"admin", "admin",
"head_of_accountant", "executive",
"accountant", "accountant",
"head_of_sale", "branch_admin",
"sale", "branch_manager",
"branch_accountant",
]; ];
function globalAllow(user: RequestWithUser["user"]) { function globalAllow(user: RequestWithUser["user"]) {
const allowList = ["system", "head_of_admin", "admin", "head_of_accountant", "head_of_sale"]; const listAllowed = ["system", "head_of_admin", "admin", "executive", "accountant"];
return allowList.some((v) => user.roles?.includes(v)); return user.roles?.some((v) => listAllowed.includes(v)) || false;
} }
type CustomerBranchCitizenPayload = { type CustomerBranchCitizenPayload = {

View file

@ -47,15 +47,16 @@ const MANAGE_ROLES = [
"system", "system",
"head_of_admin", "head_of_admin",
"admin", "admin",
"head_of_accountant", "executive",
"accountant", "accountant",
"head_of_sale", "branch_admin",
"sale", "branch_manager",
"branch_accountant",
]; ];
function globalAllow(user: RequestWithUser["user"]) { function globalAllow(user: RequestWithUser["user"]) {
const allowList = ["system", "head_of_admin", "head_of_accountant", "head_of_sale"]; const listAllowed = ["system", "head_of_admin", "admin", "executive", "accountant"];
return allowList.some((v) => user.roles?.includes(v)); return user.roles?.some((v) => listAllowed.includes(v)) || false;
} }
const permissionCondCompany = createPermCondition((_) => true); const permissionCondCompany = createPermCondition((_) => true);

View file

@ -42,15 +42,16 @@ const MANAGE_ROLES = [
"system", "system",
"head_of_admin", "head_of_admin",
"admin", "admin",
"head_of_accountant", "executive",
"accountant", "accountant",
"head_of_sale", "branch_admin",
"sale", "branch_manager",
"branch_accountant",
]; ];
function globalAllow(user: RequestWithUser["user"]) { function globalAllow(user: RequestWithUser["user"]) {
const allowList = ["system", "head_of_admin", "head_of_accountant", "head_of_sale"]; const listAllowed = ["system", "head_of_admin", "admin", "executive", "accountant"];
return allowList.some((v) => user.roles?.includes(v)); return user.roles?.some((v) => listAllowed.includes(v)) || false;
} }
const permissionCondCompany = createPermCondition((_) => true); const permissionCondCompany = createPermCondition((_) => true);

View file

@ -23,14 +23,16 @@ const MANAGE_ROLES = [
"system", "system",
"head_of_admin", "head_of_admin",
"admin", "admin",
"head_of_accountant", "executive",
"accountant", "accountant",
"head_of_sale", "branch_admin",
"branch_manager",
"branch_accountant",
]; ];
function globalAllow(user: RequestWithUser["user"]) { function globalAllow(user: RequestWithUser["user"]) {
const allowList = ["system", "head_of_admin", "head_of_accountant", "head_of_sale"]; const listAllowed = ["system", "head_of_admin", "admin", "executive", "accountant"];
return allowList.some((v) => user.roles?.includes(v)); return user.roles?.some((v) => listAllowed.includes(v)) || false;
} }
type EmployeeCheckupPayload = { type EmployeeCheckupPayload = {

View file

@ -51,14 +51,16 @@ const MANAGE_ROLES = [
"system", "system",
"head_of_admin", "head_of_admin",
"admin", "admin",
"head_of_accountant", "executive",
"accountant", "accountant",
"head_of_sale", "branch_admin",
"branch_manager",
"branch_accountant",
]; ];
function globalAllow(user: RequestWithUser["user"]) { function globalAllow(user: RequestWithUser["user"]) {
const allowList = ["system", "head_of_admin", "head_of_accountant", "head_of_sale"]; const listAllowed = ["system", "head_of_admin", "admin", "executive", "accountant"];
return allowList.some((v) => user.roles?.includes(v)); return user.roles?.some((v) => listAllowed.includes(v)) || false;
} }
const permissionCond = createPermCondition(globalAllow); const permissionCond = createPermCondition(globalAllow);

View file

@ -23,14 +23,16 @@ const MANAGE_ROLES = [
"system", "system",
"head_of_admin", "head_of_admin",
"admin", "admin",
"head_of_accountant", "executive",
"accountant", "accountant",
"head_of_sale", "branch_admin",
"branch_manager",
"branch_accountant",
]; ];
function globalAllow(user: RequestWithUser["user"]) { function globalAllow(user: RequestWithUser["user"]) {
const allowList = ["system", "head_of_admin", "head_of_accountant", "head_of_sale"]; const listAllowed = ["system", "head_of_admin", "admin", "executive", "accountant"];
return allowList.some((v) => user.roles?.includes(v)); return user.roles?.some((v) => listAllowed.includes(v)) || false;
} }
type EmployeeOtherInfoPayload = { type EmployeeOtherInfoPayload = {

View file

@ -22,14 +22,16 @@ const MANAGE_ROLES = [
"system", "system",
"head_of_admin", "head_of_admin",
"admin", "admin",
"head_of_accountant", "executive",
"accountant", "accountant",
"head_of_sale", "branch_admin",
"branch_manager",
"branch_accountant",
]; ];
function globalAllow(user: RequestWithUser["user"]) { function globalAllow(user: RequestWithUser["user"]) {
const allowList = ["system", "head_of_admin", "head_of_accountant", "head_of_sale"]; const listAllowed = ["system", "head_of_admin", "admin", "executive", "accountant"];
return allowList.some((v) => user.roles?.includes(v)); return user.roles?.some((v) => listAllowed.includes(v)) || false;
} }
type EmployeePassportPayload = { type EmployeePassportPayload = {

View file

@ -22,14 +22,16 @@ const MANAGE_ROLES = [
"system", "system",
"head_of_admin", "head_of_admin",
"admin", "admin",
"head_of_accountant", "executive",
"accountant", "accountant",
"head_of_sale", "branch_admin",
"branch_manager",
"branch_accountant",
]; ];
function globalAllow(user: RequestWithUser["user"]) { function globalAllow(user: RequestWithUser["user"]) {
const allowList = ["system", "head_of_admin", "head_of_accountant", "head_of_sale"]; const listAllowed = ["system", "head_of_admin", "admin", "executive", "accountant"];
return allowList.some((v) => user.roles?.includes(v)); return user.roles?.some((v) => listAllowed.includes(v)) || false;
} }
type EmployeeVisaPayload = { type EmployeeVisaPayload = {

View file

@ -22,14 +22,16 @@ const MANAGE_ROLES = [
"system", "system",
"head_of_admin", "head_of_admin",
"admin", "admin",
"head_of_accountant", "executive",
"accountant", "accountant",
"head_of_sale", "branch_admin",
"branch_manager",
"branch_accountant",
]; ];
function globalAllow(user: RequestWithUser["user"]) { function globalAllow(user: RequestWithUser["user"]) {
const allowList = ["system", "head_of_admin", "head_of_accountant", "head_of_sale"]; const listAllowed = ["system", "head_of_admin", "admin", "executive", "accountant"];
return allowList.some((v) => user.roles?.includes(v)); return user.roles?.some((v) => listAllowed.includes(v)) || false;
} }
type EmployeeWorkPayload = { type EmployeeWorkPayload = {