Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+33
-14
@@ -1,6 +1,7 @@
|
||||
import { useRef, useState } from "react";
|
||||
import { Form, useActionData, useLoaderData, useNavigation } from "react-router";
|
||||
import { Form, useActionData, useLoaderData, useNavigate, useNavigation } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherArrowLeft } from "@subframe/core";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import { AuthShell } from "~/components/auth/AuthShell";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
@@ -10,11 +11,6 @@ import { LinkButton } from "~/ui/components/LinkButton";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import type { ActionData, LoaderData } from "~/routeModules/auth/login-mfa.impl";
|
||||
|
||||
// D-D0a — 2FA-Code-Eingabe nach Davids Subframe-Design ("_2FA _ Code Entry"): Logo + Card
|
||||
// (Bestaetigung in zwei Schritten) + 6-stellige InputOtp + "Geraet vertrauen"-Checkbox + Bestaetigen +
|
||||
// Recovery-Code-Toggle. An die bestehende login-mfa-Action verdrahtet (code/recoveryCode/rememberDevice/csrf).
|
||||
// Die 6 OTP-Boxen werden zu einem hidden "code"-Feld kombiniert (Auto-Advance, Paste, Backspace).
|
||||
|
||||
const OTP_LENGTH = 6;
|
||||
|
||||
export default function LoginMfaRoute() {
|
||||
@@ -23,6 +19,7 @@ export default function LoginMfaRoute() {
|
||||
const data = useLoaderData<LoaderData>();
|
||||
const actionData = useActionData<ActionData>();
|
||||
const navigation = useNavigation();
|
||||
const navigate = useNavigate();
|
||||
const isSubmitting = navigation.state !== "idle";
|
||||
|
||||
const [digits, setDigits] = useState<string[]>(Array(OTP_LENGTH).fill(""));
|
||||
@@ -39,7 +36,7 @@ export default function LoginMfaRoute() {
|
||||
next[index] = "";
|
||||
return next;
|
||||
}
|
||||
// Einzelzeichen ODER Paste (z.B. "123456") ab dieser Box vorwaerts fuellen.
|
||||
|
||||
for (let k = 0; k < clean.length && index + k < OTP_LENGTH; k++) {
|
||||
next[index + k] = clean[k];
|
||||
}
|
||||
@@ -61,14 +58,24 @@ export default function LoginMfaRoute() {
|
||||
}
|
||||
}
|
||||
|
||||
function handlePaste(index: number, event: React.ClipboardEvent<HTMLInputElement>) {
|
||||
const clean = event.clipboardData.getData("text").replace(/\D/g, "");
|
||||
if (!clean) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
handleChange(index, clean);
|
||||
}
|
||||
|
||||
const errorState = Boolean(actionData?.error && navigation.state === "idle");
|
||||
|
||||
return (
|
||||
<AuthShell
|
||||
title={t("account.loginMfa.twoStepTitle")}
|
||||
subtitle={t("account.loginMfa.codeSubtitle")}
|
||||
logoIconOnly
|
||||
subtitleStrong
|
||||
subtitleVariant="medium-150"
|
||||
cardSize="extra-large"
|
||||
dataUiId="ui.auth.loginMfa.page"
|
||||
>
|
||||
<Form method="post" noValidate className="flex w-full flex-col gap-4" data-ui-id="ui.auth.loginMfa.form">
|
||||
@@ -78,10 +85,10 @@ export default function LoginMfaRoute() {
|
||||
<input type="hidden" name="rememberDevice" value={trustDevice ? "on" : ""} readOnly />
|
||||
|
||||
{!showRecovery ? (
|
||||
<div className="flex w-full flex-col items-center py-2">
|
||||
<InputOtp state={errorState ? "error" : "default"} helperText={t("account.loginMfa.codeHelper")}>
|
||||
<div className="flex w-full flex-col items-center">
|
||||
<InputOtp state={errorState ? "error" : "default"} title="" helperText={t("account.loginMfa.codeHelper")}>
|
||||
{Array.from({ length: OTP_LENGTH }).map((_, i) => (
|
||||
<InputOtp.OtpInputItem key={i} error={errorState}>
|
||||
<InputOtp.OtpInputItem key={i} error={errorState} disabled={isSubmitting}>
|
||||
<InputOtp.Input
|
||||
className="h-auto w-12 flex-none self-stretch"
|
||||
ref={(el) => {
|
||||
@@ -90,9 +97,12 @@ export default function LoginMfaRoute() {
|
||||
value={digits[i]}
|
||||
onChange={(event) => handleChange(i, event.target.value)}
|
||||
onKeyDown={(event) => handleKeyDown(i, event)}
|
||||
onPaste={(event) => handlePaste(i, event)}
|
||||
inputMode="numeric"
|
||||
autoComplete={i === 0 ? "one-time-code" : "off"}
|
||||
maxLength={OTP_LENGTH}
|
||||
disabled={isSubmitting}
|
||||
aria-invalid={errorState || undefined}
|
||||
aria-label={`${t("account.loginMfa.fields.authenticatorCode")} ${i + 1}`}
|
||||
data-ui-id={i === 0 ? "ui.auth.loginMfa.code" : undefined}
|
||||
/>
|
||||
@@ -120,7 +130,7 @@ export default function LoginMfaRoute() {
|
||||
data-ui-id="ui.auth.loginMfa.rememberDevice"
|
||||
/>
|
||||
|
||||
<Button type="submit" loading={isSubmitting} disabled={isSubmitting} data-ui-id="ui.auth.loginMfa.submit">
|
||||
<Button type="submit" className="h-9 w-full flex-none" loading={isSubmitting} disabled={isSubmitting} data-ui-id="ui.auth.loginMfa.submit">
|
||||
{t("account.loginMfa.confirm")}
|
||||
</Button>
|
||||
|
||||
@@ -131,7 +141,7 @@ export default function LoginMfaRoute() {
|
||||
) : null}
|
||||
</Form>
|
||||
|
||||
<div className="flex w-full items-center justify-center">
|
||||
<div className="flex w-full flex-col items-center justify-center gap-2">
|
||||
<LinkButton
|
||||
size="small"
|
||||
hideIcon
|
||||
@@ -140,6 +150,15 @@ export default function LoginMfaRoute() {
|
||||
>
|
||||
{showRecovery ? t("account.loginMfa.useAuthenticator") : t("account.loginMfa.useRecoveryCode")}
|
||||
</LinkButton>
|
||||
<LinkButton
|
||||
size="small"
|
||||
icon={<FeatherArrowLeft />}
|
||||
iconRight={null}
|
||||
onClick={() => navigate("/login")}
|
||||
data-ui-id="ui.auth.loginMfa.backToLogin"
|
||||
>
|
||||
{t("account.loginMfa.backToLogin")}
|
||||
</LinkButton>
|
||||
</div>
|
||||
</AuthShell>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user