mirror of
https://github.com/linsa-io/linsa.git
synced 2026-04-26 18:28:35 +02:00
16 lines
431 B
TypeScript
16 lines
431 B
TypeScript
import { createFileRoute, Outlet, redirect } from "@tanstack/react-router"
|
|
|
|
export const Route = createFileRoute("/_layout/_pages/_protected")({
|
|
beforeLoad: ({ context, location, cause }) => {
|
|
if (cause !== "stay") {
|
|
if (!context?.user?.userId) {
|
|
throw redirect({
|
|
to: "/sign-in/$",
|
|
search: { redirect_url: location.pathname },
|
|
})
|
|
}
|
|
}
|
|
},
|
|
component: () => <Outlet />,
|
|
})
|