web: switch to using /api/session/validate for determining if the user is not logged in

This commit is contained in:
rhpidfyre 2025-03-26 21:11:43 -04:00 committed by Quaternions
parent 79c21b62d8
commit 8b06a1414d
Signed by: Quaternions
GPG Key ID: D0DF5964F79AC131

@ -1,8 +1,33 @@
"use client"
import { redirect } from "next/navigation";
import { useEffect } from "react";
import Header from "./header";
async function login_check() {
try {
const response = await fetch("/api/session/validate")
if (response.ok) {
const logged_in = await response.json()
if (logged_in.code === 500) {
redirect("https://auth.staging.strafes.net/")
}
} else {
console.error("No response from /api/session/validate")
}
} catch (error) {
console.error("Error getting login status:", error)
}
}
export default function Webpage({children}: Readonly<{children?: React.ReactNode}>) {
return (<>
<Header/>
{children}
</>)
}
useEffect(() => {
login_check()
}, [])
return <>
<Header/>
{children}
</>
}