export const Route = createFileRoute("/dashboard")({
beforeLoad: ({ context, location }) => {
// Check authentication using context
console.log("[Dashboard Route Guard] Checking authentication:", {
path: location.pathname,
isAuthenticated: context.auth.isAuthenticated,
hasUser: !!context.auth.user,
userEmail: context.auth.user?.email,
hasJWT: !!context.auth.jwt,
jwtPreview: context.auth.jwt
? `${context.auth.jwt.substring(0, 20)}...`
: null,
context,
});
if (!context.auth.isAuthenticated || !context.auth.jwt) {
console.log(
"[Dashboard Route Guard] Not authenticated, redirecting to signin",
);
// eslint-disable-next-line @typescript-eslint/only-throw-error
throw redirect({
to: "/signin",
search: {
redirect: location.href,
},
});
}
export const Route = createFileRoute("/dashboard")({
beforeLoad: ({ context, location }) => {
// Check authentication using context
console.log("[Dashboard Route Guard] Checking authentication:", {
path: location.pathname,
isAuthenticated: context.auth.isAuthenticated,
hasUser: !!context.auth.user,
userEmail: context.auth.user?.email,
hasJWT: !!context.auth.jwt,
jwtPreview: context.auth.jwt
? `${context.auth.jwt.substring(0, 20)}...`
: null,
context,
});
if (!context.auth.isAuthenticated || !context.auth.jwt) {
console.log(
"[Dashboard Route Guard] Not authenticated, redirecting to signin",
);
// eslint-disable-next-line @typescript-eslint/only-throw-error
throw redirect({
to: "/signin",
search: {
redirect: location.href,
},
});
}