web: redirect if the user is not logged in based on session_id
cookie's presence
This commit is contained in:
parent
039309c75a
commit
d5d0e5ffc9
@ -1,8 +1,18 @@
|
|||||||
|
import { cookies } from "next/headers";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
import Header from "./header";
|
import Header from "./header";
|
||||||
|
|
||||||
export default function Webpage({children}: Readonly<{children?: React.ReactNode}>) {
|
export default async function Webpage({children}: Readonly<{children?: React.ReactNode}>) {
|
||||||
return (<>
|
const cookieStore = await cookies()
|
||||||
<Header/>
|
const session_id = cookieStore.get("session_id")
|
||||||
{children}
|
|
||||||
</>)
|
if (!session_id) {
|
||||||
|
redirect("https://auth.staging.strafes.net/")
|
||||||
|
return <></>
|
||||||
|
}
|
||||||
|
return <>
|
||||||
|
<Header/>
|
||||||
|
{children}
|
||||||
|
</>
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user