mirror of https://github.com/buster-so/buster.git
Update app.tsx
This commit is contained in:
parent
e31f90a6f5
commit
d22e8c8d72
|
@ -14,5 +14,6 @@ export const beforeLoad = ({
|
|||
search,
|
||||
unsafeRelative: 'path',
|
||||
replace: true,
|
||||
statusCode: 302,
|
||||
});
|
||||
};
|
||||
|
|
|
@ -14,5 +14,6 @@ export const beforeLoad = ({
|
|||
search,
|
||||
unsafeRelative: 'path',
|
||||
replace: true,
|
||||
statusCode: 302,
|
||||
});
|
||||
};
|
||||
|
|
|
@ -13,5 +13,6 @@ export const signOut = createServerFn({ method: 'POST' }).handler(async () => {
|
|||
throw redirect({
|
||||
href: '/',
|
||||
replace: true,
|
||||
statusCode: 302,
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,7 +13,6 @@ const DEFAULT_LAYOUT: LayoutSize = ['230px', 'auto'];
|
|||
|
||||
export const Route = createFileRoute('/app')({
|
||||
context: ({ context }) => ({ ...context, getAppLayout }),
|
||||
ssr: true,
|
||||
beforeLoad: async () => {
|
||||
console.log('beforeLoad app route');
|
||||
try {
|
||||
|
@ -22,7 +21,7 @@ export const Route = createFileRoute('/app')({
|
|||
|
||||
if (isExpired || !accessToken) {
|
||||
console.error('Access token is expired or not found');
|
||||
throw redirect({ to: '/auth/login', replace: true });
|
||||
throw redirect({ to: '/auth/login', replace: true, statusCode: 302 });
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -30,7 +29,7 @@ export const Route = createFileRoute('/app')({
|
|||
};
|
||||
} catch (error) {
|
||||
console.error('Error in app route beforeLoad:', error);
|
||||
throw redirect({ to: '/auth/login', replace: true });
|
||||
throw redirect({ to: '/auth/login', replace: true, statusCode: 302 });
|
||||
}
|
||||
},
|
||||
loader: async ({ context }) => {
|
||||
|
@ -45,10 +44,11 @@ export const Route = createFileRoute('/app')({
|
|||
prefetchListDatasources(queryClient),
|
||||
prefetchGetDatasets(queryClient),
|
||||
]);
|
||||
console.log('app route loaded', user);
|
||||
console.log('app route loaded', user?.id);
|
||||
|
||||
if (!user) {
|
||||
throw redirect({ to: '/auth/login', replace: true });
|
||||
console.error('User not found - redirecting to login');
|
||||
throw redirect({ to: '/auth/login', replace: true, statusCode: 302 });
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -60,7 +60,7 @@ export const Route = createFileRoute('/app')({
|
|||
};
|
||||
} catch (error) {
|
||||
console.error('Error in app route loader:', error);
|
||||
throw redirect({ to: '/auth/login', replace: true });
|
||||
throw redirect({ to: '/auth/login', replace: true, statusCode: 302 });
|
||||
}
|
||||
},
|
||||
component: () => {
|
||||
|
|
|
@ -6,6 +6,7 @@ export const Route = createFileRoute('/app/_app/datasets/$datasetId/permissions/
|
|||
to: '/app/datasets/$datasetId/permissions/overview',
|
||||
params,
|
||||
replace: true,
|
||||
statusCode: 302,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -13,6 +13,7 @@ export const Route = createFileRoute('/app/_app/datasets/$datasetId')({
|
|||
to: '/app/datasets/$datasetId/overview',
|
||||
params,
|
||||
replace: true,
|
||||
statusCode: 302,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
|
@ -9,7 +9,7 @@ export const Route = createFileRoute('/app/_settings/_permissions')({
|
|||
const { queryClient } = context;
|
||||
const userData = await prefetchGetMyUserInfo(queryClient);
|
||||
if (!userData || !userData.organizations || !checkIfUserIsAdmin(userData.organizations[0])) {
|
||||
throw redirect({ to: '/auth/login', replace: true });
|
||||
throw redirect({ to: '/auth/login', replace: true, statusCode: 302 });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -8,6 +8,7 @@ export const Route = createFileRoute(
|
|||
to: '/app/settings/dataset-groups/$datasetGroupId/datasets',
|
||||
params,
|
||||
replace: true,
|
||||
statusCode: 302,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@ export const Route = createFileRoute('/app/_settings/_restricted_layout/_admin_o
|
|||
const { queryClient } = context;
|
||||
const userData = await prefetchGetMyUserInfo(queryClient);
|
||||
if (!userData || !userData.organizations || !checkIfUserIsAdmin(userData.organizations[0])) {
|
||||
throw redirect({ to: '/auth/login', replace: true });
|
||||
throw redirect({ to: '/auth/login', replace: true, statusCode: 302 });
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ export const Route = createFileRoute('/app/_settings/settings/')({
|
|||
throw redirect({
|
||||
to: '/app/settings/profile',
|
||||
replace: true,
|
||||
statusCode: 302,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@ import { createFileRoute, redirect } from '@tanstack/react-router';
|
|||
|
||||
export const Route = createFileRoute('/app/')({
|
||||
beforeLoad: async () => {
|
||||
throw redirect({ to: '/app/home', replace: true });
|
||||
throw redirect({ to: '/app/home', replace: true, statusCode: 302 });
|
||||
},
|
||||
component: () => null,
|
||||
});
|
||||
|
|
|
@ -13,6 +13,6 @@ export const Route = createFileRoute('/auth/logout')({
|
|||
preload: false,
|
||||
loader: async () => {
|
||||
await signOut();
|
||||
throw redirect({ to: '/auth/login' });
|
||||
throw redirect({ to: '/auth/login', statusCode: 302 });
|
||||
},
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@ import { createFileRoute, redirect } from '@tanstack/react-router';
|
|||
export const Route = createFileRoute('/')({
|
||||
beforeLoad: async () => {
|
||||
console.log('redirecting to /app/home');
|
||||
throw redirect({ to: '/app/home', replace: true });
|
||||
throw redirect({ to: '/app/home', replace: true, statusCode: 302 });
|
||||
},
|
||||
component: () => null,
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue