mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-26 21:39:43 +02:00
fix(zero):refresh authenticated zero context
This commit is contained in:
parent
c8ac7d3fa6
commit
0ef8a0f2c9
3 changed files with 26 additions and 19 deletions
|
|
@ -4,14 +4,12 @@ type SpaceScopedQuery = {
|
|||
where: (...args: unknown[]) => SpaceScopedQuery;
|
||||
};
|
||||
|
||||
const DENIED_SPACE_ID = -1;
|
||||
|
||||
export function canReadSpace(ctx: Context, searchSpaceId: number): boolean {
|
||||
return !!ctx?.allowedSpaceIds?.includes(searchSpaceId);
|
||||
}
|
||||
|
||||
export function denySpace<T extends SpaceScopedQuery>(query: T): T {
|
||||
return query.where("searchSpaceId", DENIED_SPACE_ID) as T;
|
||||
return query.where(({ or }: { or: (...args: unknown[]) => unknown }) => or()) as T;
|
||||
}
|
||||
|
||||
export function constrainToAllowedSpaces<T extends SpaceScopedQuery>(query: T, ctx: Context): T {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue