mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-01 03:46:25 +02:00
fix: always render ZeroProvider, allow anon queries without 401
This commit is contained in:
parent
54ffdc5aad
commit
657f546908
2 changed files with 15 additions and 9 deletions
|
|
@ -43,17 +43,23 @@ function ZeroAuthGuard({ children }: { children: React.ReactNode }) {
|
|||
export function ZeroProvider({ children }: { children: React.ReactNode }) {
|
||||
const { data: user } = useAtomValue(currentUserAtom);
|
||||
|
||||
if (!user?.id) {
|
||||
return <>{children}</>;
|
||||
}
|
||||
const hasUser = !!user?.id;
|
||||
const userID = hasUser ? String(user.id) : "anon";
|
||||
const context = hasUser ? { userId: String(user.id) } : undefined;
|
||||
const auth = hasUser ? getBearerToken() || undefined : undefined;
|
||||
|
||||
const userID = String(user.id);
|
||||
const context = { userId: userID };
|
||||
const auth = getBearerToken() || undefined;
|
||||
const opts = {
|
||||
userID,
|
||||
schema,
|
||||
queries,
|
||||
context,
|
||||
cacheURL,
|
||||
auth,
|
||||
};
|
||||
|
||||
return (
|
||||
<ZeroReactProvider {...{ userID, context, cacheURL, schema, queries, auth }}>
|
||||
<ZeroAuthGuard>{children}</ZeroAuthGuard>
|
||||
<ZeroReactProvider {...opts}>
|
||||
{hasUser ? <ZeroAuthGuard>{children}</ZeroAuthGuard> : children}
|
||||
</ZeroReactProvider>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue