refactor(frontend): migrate LoginGate.tsx's auth_error to the banner system

This commit is contained in:
2026-07-27 10:07:00 +02:00
parent 7e960e3ce1
commit 273731442f
2 changed files with 11 additions and 6 deletions

View File

@@ -11,10 +11,6 @@
color: #e6e6e6;
}
.login-gate-error {
color: #f87171;
}
.login-gate-button {
display: inline-block;
margin-top: 1rem;

View File

@@ -1,5 +1,6 @@
import { useEffect, useState } from "react";
import { api, BASE_URL } from "./api/client";
import { showError } from "./banner";
import "./LoginGate.css";
import App from "./App";
import { OnboardingWizard } from "./OnboardingWizard";
@@ -36,16 +37,24 @@ export function LoginGate() {
.catch(() => setStatus("unauthenticated"));
}, []);
// Keycloak redirects back here with ?auth_error=<code> when the
// login-gate's own role check (not Keycloak's own authentication) rejects
// a session -- surfaced once, as a banner, the moment this screen is
// reached.
useEffect(() => {
if (status !== "unauthenticated") return;
const authError = new URLSearchParams(window.location.search).get("auth_error");
if (authError) showError(AUTH_ERROR_MESSAGES[authError] ?? "Login failed, please try again.");
}, [status]);
if (status === "loading") {
return <div className="login-gate-loading">Loading</div>;
}
if (status === "unauthenticated") {
const authError = new URLSearchParams(window.location.search).get("auth_error");
return (
<div className="login-gate">
<h1>🧞 geniusrun</h1>
{authError && <p className="login-gate-error">{AUTH_ERROR_MESSAGES[authError] ?? "Login failed, please try again."}</p>}
<a className="login-gate-button" href={`${BASE_URL}/api/session/login`}>
Log in
</a>