feat: add conditional company scope query
This commit is contained in:
parent
e0c00d4aad
commit
fdc72a7caf
1 changed files with 3 additions and 1 deletions
|
|
@ -42,6 +42,7 @@ function globalAllow(user: RequestWithUser["user"]) {
|
||||||
return allowList.some((v) => user.roles?.includes(v));
|
return allowList.some((v) => user.roles?.includes(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const permissionCondCompany = createPermCondition((_) => true);
|
||||||
const permissionCond = createPermCondition(globalAllow);
|
const permissionCond = createPermCondition(globalAllow);
|
||||||
const permissionCheck = createPermCheck(globalAllow);
|
const permissionCheck = createPermCheck(globalAllow);
|
||||||
|
|
||||||
|
|
@ -169,6 +170,7 @@ export class CustomerBranchController extends Controller {
|
||||||
async list(
|
async list(
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Query() zipCode?: string,
|
@Query() zipCode?: string,
|
||||||
|
@Query() company?: boolean,
|
||||||
@Query() customerId?: string,
|
@Query() customerId?: string,
|
||||||
@Query() registeredBranchId?: string,
|
@Query() registeredBranchId?: string,
|
||||||
@Query() status?: Status,
|
@Query() status?: Status,
|
||||||
|
|
@ -197,7 +199,7 @@ export class CustomerBranchController extends Controller {
|
||||||
: {
|
: {
|
||||||
registeredBranch: {
|
registeredBranch: {
|
||||||
AND: { id: registeredBranchId },
|
AND: { id: registeredBranchId },
|
||||||
OR: permissionCond(req.user),
|
OR: company ? permissionCondCompany(req.user) : permissionCond(req.user),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
customerId,
|
customerId,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue