feat(WEB-127): add trpc to handle requests both serverside and clientside
This commit is contained in:
21
app/[lang]/(live)/(protected)/layout.tsx
Normal file
21
app/[lang]/(live)/(protected)/layout.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
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) {
|
||||
return redirect(`/${params.lang}/login`)
|
||||
}
|
||||
|
||||
return <>{children}</>
|
||||
}
|
||||
Reference in New Issue
Block a user