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
+239
-69
@@ -1,19 +1,21 @@
|
||||
import { useEffect } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { Form, Link, useNavigate, useNavigation, useSearchParams } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherArrowLeft, FeatherMail, FeatherRotateCw, FeatherWand2 } from "@subframe/core";
|
||||
import { FeatherArrowLeft, FeatherMail, FeatherRotateCw, FeatherShieldCheck, FeatherWand2 } from "@subframe/core";
|
||||
import Captcha from "~/components/captcha/Captcha";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { LinkButton } from "~/ui/components/LinkButton";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import { AuthShell, AuthStatus, AuthDivider } from "~/components/auth/AuthShell";
|
||||
import type { LoginActionData } from "~/modules/users/components/LoginForm";
|
||||
|
||||
// Login-Screen nach Davids Subframe-Design ("Login"): Logo + Card (Anmelden/Willkommen zurueck) +
|
||||
// E-Mail/Passwort + "Passwort vergessen?" + Anmelden + "oder" + Magic-Link + Footer "Registrieren".
|
||||
// Voll an die bestehende Login-Action verdrahtet (action=login, csrf, redirectTo, Feldfehler, 2FA-Redirect).
|
||||
// Reines ~/ui (TextInput/Button/LinkButton) + AuthShell. Wird vom Login-Route fuer den NICHT-Admin-Pfad
|
||||
// gerendert; der Admin-/SSO-Pfad bleibt in login.tsx unveraendert.
|
||||
// Login screen based on David's Subframe design: logo, auth card, email/password,
|
||||
// password reset, standard login, magic-link entry point, and sign-up footer.
|
||||
// It is wired to the existing login action (`action=login`, csrf, redirectTo,
|
||||
// field errors, 2FA redirect). The admin/SSO fallback path stays in login.tsx.
|
||||
|
||||
export default function LoginScreen({
|
||||
actionData,
|
||||
@@ -23,7 +25,7 @@ export default function LoginScreen({
|
||||
redirectTo?: string;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const { csrf } = useRootData();
|
||||
const { appConfiguration, csrf } = useRootData();
|
||||
const navigation = useNavigation();
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
@@ -31,8 +33,17 @@ export default function LoginScreen({
|
||||
const mfaVerifyPath = actionData?.mfaVerifyPath ?? "/login-mfa";
|
||||
const emailError = actionData?.fieldErrors?.email;
|
||||
const passwordError = actionData?.fieldErrors?.password;
|
||||
const loginEmailRef = useRef<HTMLInputElement | null>(null);
|
||||
const [magicRequestOpen, setMagicRequestOpen] = useState(Boolean(actionData?.magicLinkRequest));
|
||||
const [magicEmail, setMagicEmail] = useState(actionData?.magicLinkEmail ?? actionData?.fields?.email ?? "");
|
||||
const showMagicRequest = !actionData?.magicLinkSent && (magicRequestOpen || Boolean(actionData?.magicLinkRequest));
|
||||
const invalidCredentials = actionData?.error === t("api.errors.invalidPassword");
|
||||
const credentialFieldError = invalidCredentials ? t("account.login.invalidCredentialsTitle") : undefined;
|
||||
const formError = actionData?.error && !actionData.requiresCaptcha ? actionData.error : undefined;
|
||||
const captchaSitekey = actionData?.sitekey ?? appConfiguration.auth.captcha.loginSiteKey;
|
||||
const compactActionButtons = Boolean(invalidCredentials || actionData?.requiresCaptcha);
|
||||
|
||||
// D1 — Passwort ok, aber 2FA noetig: Pending-Cookie ist gesetzt, jetzt zur Verify-Route.
|
||||
// D1: password is valid but 2FA is required. The pending cookie is set; redirect to verification.
|
||||
useEffect(() => {
|
||||
if (actionData?.requiresMfa) {
|
||||
navigate(mfaVerifyPath);
|
||||
@@ -54,14 +65,76 @@ export default function LoginScreen({
|
||||
);
|
||||
}
|
||||
|
||||
// D-D0a — Magic-Link ausgegeben -> Davids "Link gesendet"-Screen (AuthStatus).
|
||||
if (showMagicRequest) {
|
||||
return (
|
||||
<AuthShell
|
||||
title={t("account.login.magicLinkRequestTitle")}
|
||||
subtitle={t("account.login.magicLinkRequestSubtitle")}
|
||||
titleAlign="center"
|
||||
headerGap="gap-1.5"
|
||||
subtitleVariant="regular-150"
|
||||
dataUiId="ui.auth.login.magicLinkRequest"
|
||||
>
|
||||
<Form method="post" noValidate className="flex w-full flex-col gap-4" data-ui-id="ui.auth.login.magicLinkRequest.form">
|
||||
<input type="hidden" name="intent" value="magicLink" readOnly />
|
||||
<input type="hidden" name="csrf" value={csrf} readOnly />
|
||||
<input
|
||||
type="hidden"
|
||||
name="redirectTo"
|
||||
value={redirectTo ?? searchParams.get("redirect") ?? searchParams.get("redirectTo") ?? ""}
|
||||
readOnly
|
||||
/>
|
||||
<TextInput
|
||||
className="h-auto w-full flex-none"
|
||||
fillContainer
|
||||
showLabel
|
||||
label={t("account.shared.email")}
|
||||
helpText={emailError ?? ""}
|
||||
error={Boolean(emailError)}
|
||||
type="email"
|
||||
>
|
||||
<TextInput.Input
|
||||
name="email"
|
||||
type="email"
|
||||
required
|
||||
autoComplete="email"
|
||||
placeholder={t("account.shared.emailPlaceholder")}
|
||||
value={magicEmail}
|
||||
onChange={(event) => setMagicEmail(event.target.value)}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.login.magicEmail"
|
||||
/>
|
||||
</TextInput>
|
||||
<Button type="submit" icon={<FeatherWand2 />} loading={isSubmitting} disabled={isSubmitting} data-ui-id="ui.auth.login.magicSubmit">
|
||||
{t("account.login.magicLinkSubmit")}
|
||||
</Button>
|
||||
</Form>
|
||||
<div className="flex w-full items-center justify-center">
|
||||
<LinkButton
|
||||
size="small"
|
||||
icon={<FeatherArrowLeft />}
|
||||
iconRight={null}
|
||||
onClick={() => {
|
||||
setMagicRequestOpen(false);
|
||||
setMagicEmail("");
|
||||
}}
|
||||
data-ui-id="ui.auth.login.magicBack"
|
||||
>
|
||||
{t("account.login.backToLogin")}
|
||||
</LinkButton>
|
||||
</div>
|
||||
</AuthShell>
|
||||
);
|
||||
}
|
||||
|
||||
// D-D0a: magic link issued, show David's "link sent" status screen.
|
||||
if (actionData?.magicLinkSent) {
|
||||
return (
|
||||
<AuthStatus
|
||||
icon={<FeatherMail />}
|
||||
tone="positive"
|
||||
title={t("account.login.magicLinkSentTitle")}
|
||||
message={t("account.login.magicLinkSentBody", { email: actionData.magicLinkEmail ?? "" })}
|
||||
message={t("account.login.magicLinkSentBody")}
|
||||
hint={t("account.login.magicLinkSentHint")}
|
||||
dataUiId="ui.auth.login.magicLinkSent"
|
||||
>
|
||||
@@ -69,11 +142,36 @@ export default function LoginScreen({
|
||||
<input type="hidden" name="intent" value="magicLink" readOnly />
|
||||
<input type="hidden" name="csrf" value={csrf} readOnly />
|
||||
<input type="hidden" name="email" value={actionData.magicLinkEmail ?? ""} readOnly />
|
||||
<LinkButton type="submit" size="small" icon={<FeatherRotateCw />} disabled={isSubmitting} data-ui-id="ui.auth.login.magicLinkResend">
|
||||
<LinkButton
|
||||
type="submit"
|
||||
size="small"
|
||||
icon={<FeatherRotateCw />}
|
||||
iconRight={null}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.login.magicLinkResend"
|
||||
>
|
||||
{t("account.login.magicLinkResend")}
|
||||
</LinkButton>
|
||||
</Form>
|
||||
<LinkButton size="small" icon={<FeatherArrowLeft />} onClick={() => navigate("/login")} data-ui-id="ui.auth.login.backToLogin">
|
||||
<LinkButton
|
||||
size="small"
|
||||
icon={<FeatherMail />}
|
||||
iconRight={null}
|
||||
onClick={() => {
|
||||
setMagicEmail(actionData.magicLinkEmail ?? "");
|
||||
setMagicRequestOpen(true);
|
||||
}}
|
||||
data-ui-id="ui.auth.login.changeMagicEmail"
|
||||
>
|
||||
{t("account.login.magicLinkChangeEmail")}
|
||||
</LinkButton>
|
||||
<LinkButton
|
||||
size="small"
|
||||
icon={<FeatherArrowLeft />}
|
||||
iconRight={null}
|
||||
onClick={() => navigate("/login")}
|
||||
data-ui-id="ui.auth.login.backToLogin"
|
||||
>
|
||||
{t("account.login.backToLogin")}
|
||||
</LinkButton>
|
||||
</AuthStatus>
|
||||
@@ -85,13 +183,23 @@ export default function LoginScreen({
|
||||
title={t("account.login.title")}
|
||||
subtitle={t("account.login.headline")}
|
||||
titleAlign="center"
|
||||
headerGap="gap-1.5"
|
||||
subtitleVariant="regular-150"
|
||||
cardSize="large"
|
||||
showLogo={true}
|
||||
dataUiId="ui.auth.login.page"
|
||||
footer={
|
||||
<>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
|
||||
<span
|
||||
className={
|
||||
compactActionButtons
|
||||
? "text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary"
|
||||
: "text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary"
|
||||
}
|
||||
>
|
||||
{t("account.login.noAccount")}
|
||||
</span>
|
||||
<Link to="/register" className="no-underline" data-ui-id="ui.auth.login.register">
|
||||
<Link to="/signup" className="no-underline" data-ui-id="ui.auth.login.register">
|
||||
<LinkButton size="small" hideIcon>
|
||||
{t("account.login.register")}
|
||||
</LinkButton>
|
||||
@@ -109,76 +217,138 @@ export default function LoginScreen({
|
||||
readOnly
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
className="h-auto w-full flex-none"
|
||||
showLabel
|
||||
label={t("account.shared.email")}
|
||||
helpText={emailError ?? ""}
|
||||
error={!!emailError}
|
||||
type="email"
|
||||
>
|
||||
<TextInput.Input
|
||||
name="email"
|
||||
<div className="flex w-full flex-col items-start gap-4">
|
||||
{invalidCredentials ? (
|
||||
<Alert
|
||||
variant="error"
|
||||
notDismissible
|
||||
title={t("account.login.invalidCredentialsTitle")}
|
||||
description={t("account.login.invalidCredentialsDescription")}
|
||||
textSize="small"
|
||||
data-ui-id="ui.auth.login.invalidCredentialsAlert"
|
||||
/>
|
||||
) : null}
|
||||
{actionData?.requiresCaptcha ? (
|
||||
<>
|
||||
<Alert
|
||||
variant="warning"
|
||||
notDismissible
|
||||
title={t("account.login.captchaTitle")}
|
||||
description={t("account.login.captchaDescription")}
|
||||
textSize="small"
|
||||
data-ui-id="ui.auth.login.captchaAlert"
|
||||
/>
|
||||
<Card className="h-auto w-full flex-none" size="medium" variant="neutral" data-ui-id="ui.auth.login.captchaBlock">
|
||||
<div className="flex w-full items-center gap-2">
|
||||
<FeatherShieldCheck className="text-body-default-medium-0 font-body-default-medium-0 text-icon-neutral-tertiary" />
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("account.login.captchaLabel")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex h-12 w-full flex-none items-center justify-center rounded-sm border border-dashed border-border-default bg-surface-neutral-secondary">
|
||||
{appConfiguration.auth.captcha.enabled ? (
|
||||
<Captcha
|
||||
enabled={appConfiguration.auth.captcha.enabled}
|
||||
provider={appConfiguration.auth.captcha.provider}
|
||||
instanceUrl={appConfiguration.auth.captcha.instanceUrl}
|
||||
sitekey={captchaSitekey}
|
||||
/>
|
||||
) : (
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("account.login.captchaRequired")}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
</>
|
||||
) : null}
|
||||
<TextInput
|
||||
className="h-auto w-full flex-none"
|
||||
fillContainer
|
||||
showLabel
|
||||
label={t("account.shared.email")}
|
||||
helpText={credentialFieldError ? "" : emailError ?? ""}
|
||||
message={credentialFieldError ?? ""}
|
||||
error={Boolean(emailError || credentialFieldError)}
|
||||
type="email"
|
||||
required
|
||||
autoFocus
|
||||
autoComplete="email"
|
||||
placeholder={t("account.shared.emailPlaceholder")}
|
||||
defaultValue={actionData?.fields?.email}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.login.email"
|
||||
/>
|
||||
</TextInput>
|
||||
>
|
||||
<TextInput.Input
|
||||
ref={loginEmailRef}
|
||||
name="email"
|
||||
type="email"
|
||||
required
|
||||
autoComplete="email"
|
||||
placeholder={t("account.shared.emailPlaceholder")}
|
||||
defaultValue={actionData?.fields?.email}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.login.email"
|
||||
/>
|
||||
</TextInput>
|
||||
|
||||
<TextInput
|
||||
className="h-auto w-full flex-none"
|
||||
showLabel
|
||||
label={t("account.shared.password")}
|
||||
helpText={passwordError ?? ""}
|
||||
error={!!passwordError}
|
||||
type="password"
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
<TextInput
|
||||
className="h-auto w-full flex-none"
|
||||
fillContainer
|
||||
showLabel
|
||||
label={t("account.shared.password")}
|
||||
helpText={credentialFieldError ? "" : passwordError ?? ""}
|
||||
message={credentialFieldError ?? ""}
|
||||
error={Boolean(passwordError || credentialFieldError)}
|
||||
type="password"
|
||||
>
|
||||
<TextInput.Input
|
||||
name="password"
|
||||
type="password"
|
||||
required
|
||||
autoComplete="current-password"
|
||||
placeholder={t("account.shared.passwordPlaceholder")}
|
||||
defaultValue={actionData?.fields?.password}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.login.password"
|
||||
/>
|
||||
</TextInput>
|
||||
|
||||
<div className="flex w-full items-start justify-end">
|
||||
<Link to="/forgot-password" className="no-underline" data-ui-id="ui.auth.login.forgot">
|
||||
<LinkButton size="small" hideIcon>
|
||||
{t("account.login.forgot")}
|
||||
</LinkButton>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
size={compactActionButtons ? "medium" : "large"}
|
||||
className={compactActionButtons ? "h-9 w-full flex-none" : "h-10 w-full flex-none"}
|
||||
loading={isSubmitting}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.login.submit"
|
||||
>
|
||||
<TextInput.Input
|
||||
name="password"
|
||||
type="password"
|
||||
required
|
||||
autoComplete="current-password"
|
||||
placeholder=""
|
||||
defaultValue={actionData?.fields?.password}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.login.password"
|
||||
/>
|
||||
</TextInput>
|
||||
|
||||
<Link to="/forgot-password" className="no-underline" data-ui-id="ui.auth.login.forgot">
|
||||
<LinkButton size="small" hideIcon>
|
||||
{t("account.login.forgot")}
|
||||
</LinkButton>
|
||||
</Link>
|
||||
|
||||
<Button type="submit" loading={isSubmitting} disabled={isSubmitting} data-ui-id="ui.auth.login.submit">
|
||||
{t("account.login.button")}
|
||||
</Button>
|
||||
|
||||
{actionData?.error && navigation.state === "idle" ? (
|
||||
{formError && !invalidCredentials && navigation.state === "idle" ? (
|
||||
<p className="text-center text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-negative" role="alert">
|
||||
{actionData.error}
|
||||
{formError}
|
||||
</p>
|
||||
) : null}
|
||||
</Form>
|
||||
|
||||
<AuthDivider label={t("account.login.divider")} />
|
||||
<AuthDivider label={t("account.login.divider")} labelSize={compactActionButtons ? "small" : "extra-small"} />
|
||||
|
||||
{/* Magic-Link-Login: submitet die Login-Form (via form="loginForm") mit intent=magicLink ->
|
||||
login-Action gibt den Login-Magic-Link aus -> "Link gesendet"-Screen. */}
|
||||
<Button
|
||||
type="submit"
|
||||
form="loginForm"
|
||||
name="intent"
|
||||
value="magicLink"
|
||||
type="button"
|
||||
variant="secondary"
|
||||
size={compactActionButtons ? "medium" : "large"}
|
||||
className={compactActionButtons ? "h-9 w-full flex-none" : "h-10 w-full flex-none"}
|
||||
icon={<FeatherWand2 />}
|
||||
loading={isSubmitting}
|
||||
onClick={() => {
|
||||
setMagicEmail(loginEmailRef.current?.value ?? actionData?.fields?.email ?? "");
|
||||
setMagicRequestOpen(true);
|
||||
}}
|
||||
data-ui-id="ui.auth.login.magicLink"
|
||||
>
|
||||
{t("account.login.magicLink")}
|
||||
|
||||
Reference in new issue
Block a user