test auth fix idk
This commit is contained in:
@@ -122,26 +122,12 @@ export const Route = createRootRouteWithContext<{
|
||||
context.queryClient,
|
||||
playerQueries.auth()
|
||||
);
|
||||
|
||||
console.log('__root beforeLoad auth data:', auth);
|
||||
|
||||
return { auth };
|
||||
} catch (error: any) {
|
||||
if (typeof window !== 'undefined') {
|
||||
const { doesSessionExist } = await import('supertokens-web-js/recipe/session');
|
||||
const { refreshManager } = await import('@/lib/supertokens/refresh-manager');
|
||||
|
||||
const sessionExists = await doesSessionExist();
|
||||
if (sessionExists) {
|
||||
try {
|
||||
await refreshManager.refresh();
|
||||
const auth = await ensureServerQueryData(
|
||||
context.queryClient,
|
||||
playerQueries.auth()
|
||||
);
|
||||
return { auth };
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
||||
console.error('__root beforeLoad error:', error);
|
||||
return {};
|
||||
}
|
||||
},
|
||||
|
||||
@@ -5,10 +5,14 @@ import { Flex, Loader } from "@mantine/core";
|
||||
|
||||
export const Route = createFileRoute("/_authed")({
|
||||
beforeLoad: ({ context }) => {
|
||||
console.log('_authed beforeLoad context:', context.auth);
|
||||
|
||||
if (!context.auth?.user) {
|
||||
console.log('_authed: No user in context, redirecting to login');
|
||||
throw redirect({ to: "/login" });
|
||||
}
|
||||
|
||||
console.log('_authed: User found, allowing access');
|
||||
return {
|
||||
auth: {
|
||||
...context.auth,
|
||||
|
||||
Reference in New Issue
Block a user