fix: wrong condition
This commit is contained in:
parent
5049392caf
commit
d558aa3cf2
1 changed files with 7 additions and 3 deletions
|
|
@ -21,7 +21,12 @@ export function permissionCheck(globalAllow: (user: RequestWithUser["user"]) =>
|
|||
user: {
|
||||
where: { userId: req.user.sub },
|
||||
},
|
||||
headOffice: {
|
||||
branch: {
|
||||
where: {
|
||||
user: {
|
||||
some: { userId: req.user.sub },
|
||||
},
|
||||
},
|
||||
include: {
|
||||
user: {
|
||||
where: { userId: req.user.sub },
|
||||
|
|
@ -44,8 +49,7 @@ export function permissionCheck(globalAllow: (user: RequestWithUser["user"]) =>
|
|||
if (!isSystem(req.user)) {
|
||||
const _branch = employee.customerBranch.customer.registeredBranch;
|
||||
const affilationBranch = _branch && _branch.user.length !== 0;
|
||||
const affilationHeadBranch =
|
||||
_branch && _branch.headOffice && _branch.headOffice.user.length !== 0;
|
||||
const affilationHeadBranch = _branch && _branch.branch.every((v) => v.user.length !== 0);
|
||||
if (!globalAllow(req.user)) {
|
||||
if (!affilationBranch) {
|
||||
throw new HttpError(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue