fix: regression perm not work as expected after activeOnly opts
This commit is contained in:
parent
c4d2349114
commit
eb8e311d3d
1 changed files with 32 additions and 31 deletions
|
|
@ -40,37 +40,38 @@ export function createPermCondition(
|
||||||
? undefined
|
? undefined
|
||||||
: [
|
: [
|
||||||
{
|
{
|
||||||
status: opts?.activeOnly ? { not: Status.INACTIVE } : undefined,
|
AND: opts?.activeOnly ? { status: { not: Status.INACTIVE } } : undefined,
|
||||||
user: { some: { userId: user.sub } },
|
OR: [
|
||||||
},
|
{
|
||||||
{
|
user: { some: { userId: user.sub } },
|
||||||
status: opts?.activeOnly ? { not: Status.INACTIVE } : undefined,
|
},
|
||||||
branch:
|
{
|
||||||
opts?.alwaysIncludeHead || globalAllow(user)
|
branch:
|
||||||
? {
|
opts?.alwaysIncludeHead || globalAllow(user)
|
||||||
some: { user: { some: { userId: user.sub } } },
|
? {
|
||||||
}
|
some: { user: { some: { userId: user.sub } } },
|
||||||
: undefined,
|
}
|
||||||
},
|
: undefined,
|
||||||
{
|
},
|
||||||
headOffice: globalAllow(user)
|
{
|
||||||
? {
|
headOffice: globalAllow(user)
|
||||||
status: opts?.activeOnly ? { not: Status.INACTIVE } : undefined,
|
? {
|
||||||
branch: {
|
status: opts?.activeOnly ? { not: Status.INACTIVE } : undefined,
|
||||||
some: { user: { some: { userId: user.sub } } },
|
branch: {
|
||||||
},
|
some: { user: { some: { userId: user.sub } } },
|
||||||
}
|
},
|
||||||
: undefined,
|
}
|
||||||
status: opts?.activeOnly ? { not: Status.INACTIVE } : undefined,
|
: undefined,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
headOffice: globalAllow(user)
|
headOffice: globalAllow(user)
|
||||||
? {
|
? {
|
||||||
status: opts?.activeOnly ? { not: Status.INACTIVE } : undefined,
|
status: opts?.activeOnly ? { not: Status.INACTIVE } : undefined,
|
||||||
user: { some: { userId: user.sub } },
|
user: { some: { userId: user.sub } },
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
status: opts?.activeOnly ? { not: Status.INACTIVE } : undefined,
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue