mirror of https://github.com/buster-so/buster.git
route guard the index
This commit is contained in:
parent
bd37c7717b
commit
66623fb2a5
|
@ -1,11 +1,14 @@
|
||||||
import { createFileRoute } from '@tanstack/react-router';
|
import { createFileRoute, redirect } from '@tanstack/react-router';
|
||||||
import logo from '../logo.svg';
|
import logo from '../logo.svg';
|
||||||
|
|
||||||
export const Route = createFileRoute('/')({
|
export const Route = createFileRoute('/')({
|
||||||
component: App,
|
component: App,
|
||||||
beforeLoad: async ({ context }) => {
|
beforeLoad: async ({ context }) => {
|
||||||
const hasUser = context.user;
|
const hasUser = context.user;
|
||||||
console.log('hasUser', hasUser);
|
const isAnonymous = context.user?.is_anonymous;
|
||||||
|
if (!hasUser || isAnonymous) {
|
||||||
|
throw redirect({ to: '/auth/login' });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue