Switch to using /api/session/validate for determining if the user is not logged in #34

Merged
Quaternions merged 2 commits from frontend/login into staging 2025-03-27 21:47:04 +00:00

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