fix: regression perm not work as expected after activeOnly opts

This commit is contained in:
Methapon2001 2024-12-12 10:15:22 +07:00
parent c4d2349114
commit eb8e311d3d

View file

@ -40,11 +40,12 @@ export function createPermCondition(
? undefined ? undefined
: [ : [
{ {
status: opts?.activeOnly ? { not: Status.INACTIVE } : undefined, AND: opts?.activeOnly ? { status: { not: Status.INACTIVE } } : undefined,
OR: [
{
user: { some: { userId: user.sub } }, user: { some: { userId: user.sub } },
}, },
{ {
status: opts?.activeOnly ? { not: Status.INACTIVE } : undefined,
branch: branch:
opts?.alwaysIncludeHead || globalAllow(user) opts?.alwaysIncludeHead || globalAllow(user)
? { ? {
@ -61,7 +62,6 @@ export function createPermCondition(
}, },
} }
: undefined, : undefined,
status: opts?.activeOnly ? { not: Status.INACTIVE } : undefined,
}, },
{ {
headOffice: globalAllow(user) headOffice: globalAllow(user)
@ -70,7 +70,8 @@ export function createPermCondition(
user: { some: { userId: user.sub } }, user: { some: { userId: user.sub } },
} }
: undefined, : undefined,
status: opts?.activeOnly ? { not: Status.INACTIVE } : undefined, },
],
}, },
]; ];
} }