web: use param ?redirect=
with auth redirection and switch to a boolean check for /api/session/validate
This commit is contained in:
parent
8b06a1414d
commit
d089872432
@ -6,25 +6,19 @@ import { useEffect } from "react";
|
|||||||
import Header from "./header";
|
import Header from "./header";
|
||||||
|
|
||||||
async function login_check() {
|
async function login_check() {
|
||||||
try {
|
const response = await fetch("/api/session/validate")
|
||||||
const response = await fetch("/api/session/validate")
|
if (response.ok) {
|
||||||
if (response.ok) {
|
const logged_in = await response.json()
|
||||||
const logged_in = await response.json()
|
if (!logged_in) {
|
||||||
if (logged_in.code === 500) {
|
redirect("https://auth.staging.strafes.net/oauth2/login?redirect=" + window.location.href)
|
||||||
redirect("https://auth.staging.strafes.net/")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.error("No response from /api/session/validate")
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} else {
|
||||||
console.error("Error getting login status:", error)
|
console.error("No response from /api/session/validate")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Webpage({children}: Readonly<{children?: React.ReactNode}>) {
|
export default function Webpage({children}: Readonly<{children?: React.ReactNode}>) {
|
||||||
useEffect(() => {
|
useEffect(() => { login_check() }, [])
|
||||||
login_check()
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
<Header/>
|
<Header/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user