Files
web/app/[lang]/(live)/(protected)/layout.tsx
2024-05-20 00:51:16 +02:00

22 lines
490 B
TypeScript

import { redirect } from "next/navigation"
import { auth } from "@/auth"
import type { LangParams, LayoutArgs } from "@/types/params"
export default async function ProtectedLayout({
children,
params,
}: React.PropsWithChildren<LayoutArgs<LangParams>>) {
const session = await auth()
/**
* Fallback to make sure every route nested in the
* protected route group is actually protected.
*/
if (!session) {
redirect(`/${params.lang}/login`)
}
return children
}