mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-11 20:05:25 +00:00
enforce permitted user check even when no where clause
This commit is contained in:
parent
0bd545359e
commit
b939d1e420
1 changed files with 20 additions and 20 deletions
|
|
@ -27,27 +27,27 @@ export const userScopedPrismaClientExtension = (userId?: string) => {
|
||||||
query: {
|
query: {
|
||||||
...(env.EXPERIMENT_EE_PERMISSION_SYNC_ENABLED === 'true' && hasEntitlement('permission-syncing') ? {
|
...(env.EXPERIMENT_EE_PERMISSION_SYNC_ENABLED === 'true' && hasEntitlement('permission-syncing') ? {
|
||||||
repo: {
|
repo: {
|
||||||
$allOperations({ args, query }) {
|
async $allOperations({ args, query }) {
|
||||||
if ('where' in args) {
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
args.where = {
|
const argsWithWhere = args as any;
|
||||||
...args.where,
|
argsWithWhere.where = {
|
||||||
OR: [
|
...(argsWithWhere.where || {}),
|
||||||
// Only include repos that are permitted to the user
|
OR: [
|
||||||
...(userId ? [
|
// Only include repos that are permitted to the user
|
||||||
{
|
...(userId ? [
|
||||||
permittedUsers: {
|
|
||||||
some: {
|
|
||||||
userId,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
] : []),
|
|
||||||
// or are public.
|
|
||||||
{
|
{
|
||||||
isPublic: true,
|
permittedUsers: {
|
||||||
}
|
some: {
|
||||||
]
|
userId,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
] : []),
|
||||||
|
// or are public.
|
||||||
|
{
|
||||||
|
isPublic: true,
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
return query(args);
|
return query(args);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue