web: auth redirect fix
This commit is contained in:
parent
d3edb6b3da
commit
a9afdf38cf
@ -1,16 +1,20 @@
|
|||||||
import { cookies } from "next/headers";
|
"use client"
|
||||||
|
|
||||||
|
import { useEffect } from "react";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
import Header from "./header";
|
import Header from "./header";
|
||||||
|
|
||||||
export default async function Webpage({children}: Readonly<{children?: React.ReactNode}>) {
|
export default function Webpage({children}: Readonly<{children?: React.ReactNode}>) {
|
||||||
const cookieStore = await cookies()
|
//check if the user is logged into the auth
|
||||||
const session_id = cookieStore.get("session_id")
|
useEffect(() => {
|
||||||
|
const cookies = document.cookie.split("; ")
|
||||||
|
const hasCookie = cookies.some(cookie => cookie.startsWith("session_id="))
|
||||||
|
if (!hasCookie) {
|
||||||
|
redirect("https://auth.staging.strafes.net/")
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
if (!session_id) {
|
|
||||||
redirect("https://auth.staging.strafes.net/")
|
|
||||||
return <></>
|
|
||||||
}
|
|
||||||
return <>
|
return <>
|
||||||
<Header/>
|
<Header/>
|
||||||
{children}
|
{children}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user