web: auth redirect fix

This commit is contained in:
rhpidfyre 2025-03-26 19:16:09 -04:00 committed by Quaternions
parent d3edb6b3da
commit a9afdf38cf
Signed by: Quaternions
GPG Key ID: D0DF5964F79AC131

@ -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}