fix(35-01): replace login page card UI with immediate useEffect redirect (FIX-04)
- Remove auth check, useNavigate, useTranslation, and full card UI - LoginPage now renders only "Signing in..." and immediately navigates to server /login - Server /login route handles Logto OIDC redirect; no client-side logic needed
This commit is contained in:
@@ -1,52 +1,18 @@
|
|||||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { useAuth } from "../hooks/useAuth";
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/login")({
|
export const Route = createFileRoute("/login")({
|
||||||
component: LoginPage,
|
component: LoginPage,
|
||||||
});
|
});
|
||||||
|
|
||||||
function LoginPage() {
|
function LoginPage() {
|
||||||
const { t } = useTranslation();
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const { data: auth, isLoading } = useAuth();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (auth?.authenticated) {
|
|
||||||
navigate({ to: "/" });
|
|
||||||
}
|
|
||||||
}, [auth, navigate]);
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return (
|
|
||||||
<div className="min-h-screen bg-gray-50 flex items-center justify-center">
|
|
||||||
<p className="text-gray-500 text-sm">{t("actions.loading")}</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="min-h-screen bg-gray-50 flex items-center justify-center px-4">
|
|
||||||
<div className="w-full max-w-sm">
|
|
||||||
<h1 className="text-xl font-semibold text-gray-900 text-center mb-6">
|
|
||||||
{t("auth.signInToGearBox")}
|
|
||||||
</h1>
|
|
||||||
<div className="bg-white rounded-xl border border-gray-100 p-6 space-y-4">
|
|
||||||
<p className="text-sm text-gray-500 text-center">
|
|
||||||
{t("auth.redirectDescription")}
|
|
||||||
</p>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => {
|
|
||||||
window.location.href = "/login";
|
window.location.href = "/login";
|
||||||
}}
|
}, []);
|
||||||
className="w-full py-2 px-4 text-sm font-medium text-white bg-gray-700 hover:bg-gray-800 rounded-lg transition-colors"
|
|
||||||
>
|
return (
|
||||||
{t("auth.signIn")}
|
<div className="flex items-center justify-center h-screen">
|
||||||
</button>
|
<p className="text-sm text-gray-500">Signing in...</p>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user