web: auth redirect fix

This commit is contained in:
rhpidfyre 2025-03-26 19:16:09 -04:00
parent badd3abe6f
commit 2f4c88689c

@ -1,16 +1,20 @@
import { cookies } from "next/headers";
"use client"
import { useEffect } from "react";
import { redirect } from "next/navigation";
import Header from "./header";
export default async function Webpage({children}: Readonly<{children?: React.ReactNode}>) {
const cookieStore = await cookies()
const session_id = cookieStore.get("session_id")
export default function Webpage({children}: Readonly<{children?: React.ReactNode}>) {
//check if the user is logged into the auth
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 <>
<Header/>
{children}