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
+77
-15
@@ -1,16 +1,18 @@
|
||||
import { useState } from "react";
|
||||
import { Form, useNavigate, useNavigation } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherMail } from "@subframe/core";
|
||||
import { FeatherArrowLeft, FeatherMail, FeatherRotateCw, FeatherX } from "@subframe/core";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import { AuthShell, AuthStatus } from "~/components/auth/AuthShell";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { LinkButton } from "~/ui/components/LinkButton";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
// Forgot-Password-Screen nach Davids Subframe-Design ("Login_Forgot password" + "_ Sent"): Logo + Card
|
||||
// (Passwort vergessen? + E-Mail + "Link senden") -> action (mode=reset) gibt den Reset-Link aus ->
|
||||
// Davids "E-Mail gesendet"-Status. Magic-Link-Alternative liegt jetzt im Login-Screen, daher hier nur reset.
|
||||
// Forgot-Password-Screen nach Davids WF-P2-Subframe-Design ("S01 Passwort Reset anfordern" + "S02 Reset-Link
|
||||
// gesendet"): Card (Passwort vergessen? + E-Mail-Adresse + "Reset-Link senden") -> action (mode=reset) gibt den
|
||||
// Reset-Link aus -> Davids "Anweisungen gesendet"-Status (AuthStatus). Der Magic-Link-Hinweis lebt seit dem
|
||||
// Anti-Enumeration-Fix (Security-Audit #9) hier: generisch auf dem Sent-State, damit die Login-Antwort nicht
|
||||
// mehr verrät, ob ein Konto passwortlos ist.
|
||||
|
||||
export default function ForgotPasswordScreen({
|
||||
actionData,
|
||||
@@ -31,18 +33,37 @@ export default function ForgotPasswordScreen({
|
||||
tone="positive"
|
||||
title={t("account.forgot.sentTitle")}
|
||||
message={t("account.forgot.sentBody", { email })}
|
||||
hint={t("account.login.magicLinkSentHint")}
|
||||
hint={t("account.forgot.sentHint")}
|
||||
dataUiId="ui.auth.forgot.sent"
|
||||
>
|
||||
{/* Generic, non-enumerating magic-link hint: shown to everyone on the
|
||||
sent state so invited/passwordless users know the link signs them in,
|
||||
without the login response revealing whether an account is passwordless. */}
|
||||
<p className="text-center text-body-small-regular-0 font-body-small-regular-0 text-subtext-color" data-ui-id="ui.auth.forgot.magicLinkNote">
|
||||
{t("auth:errors.passwordlessAccountUseMagicLink")}
|
||||
</p>
|
||||
<Form method="post" className="contents">
|
||||
<input type="hidden" name="csrf" value={csrf} readOnly />
|
||||
<input type="hidden" name="mode" value="reset" readOnly />
|
||||
<input type="hidden" name="email" value={email} readOnly />
|
||||
<LinkButton type="submit" size="small" hideIcon disabled={isSubmitting} data-ui-id="ui.auth.forgot.resend">
|
||||
{t("account.login.magicLinkResend")}
|
||||
<LinkButton
|
||||
type="submit"
|
||||
size="small"
|
||||
icon={<FeatherRotateCw />}
|
||||
iconRight={null}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.forgot.resend"
|
||||
>
|
||||
{t("account.forgot.resend")}
|
||||
</LinkButton>
|
||||
</Form>
|
||||
<LinkButton size="small" hideIcon onClick={() => navigate("/login")} data-ui-id="ui.auth.forgot.backToLogin">
|
||||
<LinkButton
|
||||
size="small"
|
||||
icon={<FeatherArrowLeft />}
|
||||
iconRight={null}
|
||||
onClick={() => navigate("/login")}
|
||||
data-ui-id="ui.auth.forgot.backToLogin"
|
||||
>
|
||||
{t("account.forgot.backToLogin")}
|
||||
</LinkButton>
|
||||
</AuthStatus>
|
||||
@@ -50,11 +71,26 @@ export default function ForgotPasswordScreen({
|
||||
}
|
||||
|
||||
return (
|
||||
<AuthShell title={t("account.forgot.title")} subtitle={t("account.forgot.subtitle")} subtitleStrong dataUiId="ui.auth.forgot.page">
|
||||
<AuthShell
|
||||
title={t("account.forgot.title")}
|
||||
subtitle={t("account.forgot.subtitle")}
|
||||
cardSize="large"
|
||||
showLogo={true}
|
||||
titleAlign="center"
|
||||
headerGap="gap-2"
|
||||
subtitleVariant="regular-150"
|
||||
dataUiId="ui.auth.forgot.page"
|
||||
>
|
||||
<Form method="post" noValidate className="flex w-full flex-col gap-4" data-ui-id="ui.auth.forgot.form">
|
||||
<input type="hidden" name="csrf" value={csrf} readOnly />
|
||||
|
||||
<TextInput className="h-auto w-full flex-none" showLabel label={t("account.shared.email")} type="email">
|
||||
<TextInput
|
||||
className="h-auto w-full flex-none"
|
||||
fillContainer
|
||||
showLabel
|
||||
label={t("account.forgot.emailLabel")}
|
||||
type="email"
|
||||
>
|
||||
<TextInput.Input
|
||||
name="email"
|
||||
type="email"
|
||||
@@ -69,9 +105,20 @@ export default function ForgotPasswordScreen({
|
||||
/>
|
||||
</TextInput>
|
||||
|
||||
<Button type="submit" name="mode" value="reset" loading={isSubmitting} disabled={isSubmitting} data-ui-id="ui.auth.forgot.submit">
|
||||
{t("account.forgot.sendLink")}
|
||||
</Button>
|
||||
<div className="flex w-full flex-col items-center gap-3">
|
||||
<Button
|
||||
className="h-9 w-full flex-none"
|
||||
type="submit"
|
||||
name="mode"
|
||||
value="reset"
|
||||
icon={<FeatherMail />}
|
||||
loading={isSubmitting}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.forgot.submit"
|
||||
>
|
||||
{t("account.forgot.sendLink")}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{actionData?.error && navigation.state === "idle" ? (
|
||||
<p className="text-center text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-negative" role="alert">
|
||||
@@ -80,8 +127,23 @@ export default function ForgotPasswordScreen({
|
||||
) : null}
|
||||
</Form>
|
||||
|
||||
<div className="flex w-full items-center justify-center">
|
||||
<LinkButton size="small" hideIcon onClick={() => navigate("/login")} data-ui-id="ui.auth.forgot.backToLoginLink">
|
||||
<div className="flex w-full items-center justify-center gap-6">
|
||||
<LinkButton
|
||||
size="small"
|
||||
icon={<FeatherX />}
|
||||
iconRight={null}
|
||||
onClick={() => navigate("/login")}
|
||||
data-ui-id="ui.auth.forgot.cancel"
|
||||
>
|
||||
{t("account.forgot.cancel")}
|
||||
</LinkButton>
|
||||
<LinkButton
|
||||
size="small"
|
||||
icon={<FeatherArrowLeft />}
|
||||
iconRight={null}
|
||||
onClick={() => navigate("/login")}
|
||||
data-ui-id="ui.auth.forgot.backToLoginLink"
|
||||
>
|
||||
{t("account.forgot.backToLogin")}
|
||||
</LinkButton>
|
||||
</div>
|
||||
|
||||
+19
-1
@@ -16,7 +16,16 @@ import { useRootData } from "~/utils/data/useRootData";
|
||||
// Praesentational: items + csrf injiziert; Anlegen/Bearbeiten via bestehende Routen (new / $id im SlideOver),
|
||||
// Löschen via Form-POST an den $id-Pfad (action=delete). Empty-/Loading-States nach Davids Vorlage.
|
||||
|
||||
export default function GroupsListView({ items, canManage }: { items: GroupWithDetails[]; canManage: boolean }) {
|
||||
export default function GroupsListView({
|
||||
items,
|
||||
canManage,
|
||||
onManageMembers,
|
||||
}: {
|
||||
items: GroupWithDetails[];
|
||||
canManage: boolean;
|
||||
/** R-P2b bulk interim UI (AD-28): opens the group members dialog when provided. */
|
||||
onManageMembers?: (groupId: string) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const { csrf = "" } = useRootData();
|
||||
const navigation = useNavigation();
|
||||
@@ -112,6 +121,15 @@ export default function GroupsListView({ items, canManage }: { items: GroupWithD
|
||||
<Link to={group.id} className="no-underline">
|
||||
<DropdownMenu.DropdownItem icon={<FeatherEdit2 />}>{t("shared.edit")}</DropdownMenu.DropdownItem>
|
||||
</Link>
|
||||
{onManageMembers ? (
|
||||
<DropdownMenu.DropdownItem
|
||||
icon={<FeatherUsers />}
|
||||
onClick={() => onManageMembers(group.id)}
|
||||
data-ui-id="ui.settings.groups.manageMembers"
|
||||
>
|
||||
{t("settings.members.groups.bulk.manageAction")}
|
||||
</DropdownMenu.DropdownItem>
|
||||
) : null}
|
||||
<DropdownMenu.DropdownItem icon={<FeatherTrash />} onClick={() => setConfirmDelete({ id: group.id, name: group.name })}>
|
||||
{t("shared.delete")}
|
||||
</DropdownMenu.DropdownItem>
|
||||
|
||||
+9
-4
@@ -17,14 +17,19 @@ export type LoginActionData = {
|
||||
password: string;
|
||||
};
|
||||
/**
|
||||
* D1 — gesetzt, wenn das Passwort stimmt, der Nutzer aber 2FA aktiviert hat. Das Session-Cookie
|
||||
* traegt dann nur den Pending-Zustand; der Client wird zur Verify-Route (`mfaVerifyPath`) geleitet.
|
||||
* D1: set when the password is valid but the user has 2FA enabled. The session cookie only
|
||||
* carries the pending state; the client redirects to the verification route (`mfaVerifyPath`).
|
||||
*/
|
||||
requiresMfa?: boolean;
|
||||
mfaVerifyPath?: string;
|
||||
/** D-D0a — Magic-Link-Login: gesetzt, wenn der Anmeldelink ausgegeben wurde (zeigt den "Link gesendet"-Screen). */
|
||||
/** D-D0a magic-link login: set after issuing the sign-in link, which shows the "link sent" screen. */
|
||||
magicLinkSent?: boolean;
|
||||
magicLinkEmail?: string;
|
||||
/** D-D0a: shows David's separate S02 magic-link request state. */
|
||||
magicLinkRequest?: boolean;
|
||||
/** R-P2a brute-force soft gate: requires mCaptcha after repeated failed attempts. */
|
||||
requiresCaptcha?: boolean;
|
||||
sitekey?: string;
|
||||
};
|
||||
|
||||
export default function LoginForm({ actionData, redirectTo }: { actionData: LoginActionData | null | undefined; redirectTo?: string }) {
|
||||
@@ -71,7 +76,7 @@ export default function LoginForm({ actionData, redirectTo }: { actionData: Logi
|
||||
<h1 className="text-left text-2xl font-extrabold">{t("account.login.headline")}</h1>
|
||||
{appConfiguration.subscription.allowSignUpBeforeSubscribe && (
|
||||
<p className="mt-1 text-left">
|
||||
<Link to="/register" className="text-primary font-medium hover:underline">
|
||||
<Link to="/signup" className="text-primary font-medium hover:underline">
|
||||
{t("account.login.orRegister")}
|
||||
</Link>
|
||||
</p>
|
||||
|
||||
+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")}
|
||||
|
||||
+643
-251
File diff suppressed because it is too large.
Load diff
+1
@@ -41,6 +41,7 @@ vi.mock("~/utils/data/useRootData", () => ({
|
||||
},
|
||||
captcha: {
|
||||
enabled: false,
|
||||
provider: "mcaptcha",
|
||||
instanceUrl: undefined,
|
||||
loginSiteKey: undefined,
|
||||
},
|
||||
|
||||
+1
@@ -194,6 +194,7 @@ export const RegisterForm = ({
|
||||
|
||||
<Captcha
|
||||
enabled={requireCaptcha && appConfiguration.auth.captcha.enabled}
|
||||
provider={appConfiguration.auth.captcha.provider}
|
||||
instanceUrl={appConfiguration.auth.captcha.instanceUrl}
|
||||
sitekey={appConfiguration.auth.captcha.loginSiteKey}
|
||||
/>
|
||||
|
||||
+237
-134
@@ -1,26 +1,40 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { Form, Link, useNavigation, useSearchParams } from "react-router";
|
||||
import { Form, Link, useNavigate, useNavigation, useSearchParams } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherMail } from "@subframe/core";
|
||||
import { FeatherArrowLeft, FeatherBuilding, FeatherMail, FeatherMailCheck, FeatherPencil, FeatherRotateCw } from "@subframe/core";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import { AuthShell, AuthStatus } from "~/components/auth/AuthShell";
|
||||
import { AuthShell } from "~/components/auth/AuthShell";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { IconWithBackground } from "~/ui/components/IconWithBackground";
|
||||
import { LinkButton } from "~/ui/components/LinkButton";
|
||||
import { Logo } from "~/ui/components/Logo";
|
||||
import { Progress } from "~/ui/components/Progress";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import Captcha from "~/components/captcha/Captcha";
|
||||
import { getPasswordChecks, type PasswordPolicy } from "~/modules/users/components/RegisterForm";
|
||||
|
||||
// Signup-Screen nach Davids Subframe-Design ("Signup"): Logo + Card (Konto erstellen) + E-Mail, Passwort
|
||||
// (+ Staerke-Progress), Firmenname, Vor-/Nachname, Telefon, USt-IdNr, 3 Consent-Checkboxen + "Konto erstellen".
|
||||
// Voll an die bestehende Register-Action verdrahtet (gleiche Feld-Namen, Password-Policy, Captcha, Lead-Felder).
|
||||
// verificationEmailSent -> Davids Success-Status. Footer "Schon ein Konto? Anmelden".
|
||||
// Signup-Screens nach Davids Subframe-"WF-P2"-Designs:
|
||||
// S01 "Signup" -> Form (Logo + Card "Konto erstellen": E-Mail, Passwort+Staerke, Vor-/Nachname,
|
||||
// Firmenname, Sicherheitspruefung/Captcha, 2 Consents, "Konto erstellen").
|
||||
// S03 "E-Mail bestaetigen" -> verificationEmailSent-Status (Logo + Card: Mail-Check-Icon, Titel, gesendete
|
||||
// Adresse, Hinweis-Alert, "E-Mail erneut senden" / "E-Mail aendern" / "Zur Anmeldung").
|
||||
// Voll an die bestehende Register-Action verdrahtet (Feld-Namen, Password-Policy, Captcha, Lead-Felder).
|
||||
//
|
||||
// 💡 Backend-Luecken (gerendert + gepostet, aber von registerFromRequest noch nicht persistiert):
|
||||
// - phone: User-Modell hat die Spalte (accounts.prisma) -> Action muss das Feld nur noch lesen.
|
||||
// - vatNumber (USt-IdNr): keine Spalte im LOCKED-Modell -> braucht Data-Model-Entscheidung.
|
||||
// - 3 Consents: Backend nutzt impliziten Terms-Consent; hier als Client-Gate (kein Server-Tracking).
|
||||
// Token-genaue Uebernahme + bewusste Abweichungen (vom Backend erzwungen, nicht erfunden):
|
||||
// - Davids S01 zeigt das Passwort IMMER. Bei aktiver E-Mail-Verifizierung sammelt das Backend das Passwort
|
||||
// aber erst beim Verify (Registration-Modell hat KEINE Passwort-Spalte) -> showPasswordInput bleibt
|
||||
// `!requireEmailVerification` (Default ist OFF -> Passwort sichtbar = Davids Optik). [Backend-Flag]
|
||||
// - Davids S01 hat KEIN Telefon-/USt-IdNr-Feld -> entfernt (wurden ohnehin nie persistiert).
|
||||
// - Davids S01 hat 2 Consents (AGB, Datenschutz); der separate AVV/DPA-Consent wurde gestrichen. [Flag]
|
||||
// - Davids PasswordStrengthIndicator existiert nicht in ~/ui -> bestehender Progress-Balken beibehalten.
|
||||
// - Davids statische Captcha-Box ("Ich bin kein Roboter") -> echtes mCaptcha-Widget in Davids Box-Optik,
|
||||
// nur sichtbar wenn Captcha aktiv ist.
|
||||
// - S03 "E-Mail erneut senden": echtes Resend braucht `recreateToken:true` (registerFromRequest nutzt
|
||||
// `false` -> versendet bei bestehender Registration NICHTS). Button postet `intent=resendVerification`;
|
||||
// das Backend muss diesen Intent noch auf createRegistrationForm({recreateToken:true}) mappen. [Backend-Flag]
|
||||
|
||||
type RegisterData = { company?: string; firstName?: string; lastName?: string; email?: string; slug?: string };
|
||||
|
||||
@@ -42,47 +56,115 @@ export default function RegisterScreen({
|
||||
const { t } = useTranslation();
|
||||
const { appConfiguration, csrf } = useRootData();
|
||||
const navigation = useNavigation();
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
const isSubmitting = navigation.state !== "idle";
|
||||
const redirect = searchParams.get("redirect") ?? "";
|
||||
|
||||
// Controlled, damit Werte ueber den Wechsel Form <-> "E-Mail bestaetigt"-Status erhalten bleiben
|
||||
// (E-Mail-Anzeige in S03, Resend ohne erneutes Tippen).
|
||||
const [email, setEmail] = useState(data.email ?? "");
|
||||
const [password, setPassword] = useState("");
|
||||
const [company, setCompany] = useState(data.company ?? "");
|
||||
const [firstName, setFirstName] = useState(data.firstName ?? "");
|
||||
const [lastName, setLastName] = useState(data.lastName ?? "");
|
||||
const [acceptTerms, setAcceptTerms] = useState(false);
|
||||
const [acceptPrivacy, setAcceptPrivacy] = useState(false);
|
||||
const [acceptDpa, setAcceptDpa] = useState(false);
|
||||
const allConsents = acceptTerms && acceptPrivacy && acceptDpa;
|
||||
const allConsents = acceptTerms && acceptPrivacy;
|
||||
|
||||
const showPasswordInput = !appConfiguration.auth.requireEmailVerification;
|
||||
const requireEmailVerification = appConfiguration.auth.requireEmailVerification;
|
||||
const showPasswordInput = !requireEmailVerification;
|
||||
const captchaEnabled = requireCaptcha && appConfiguration.auth.captcha.enabled;
|
||||
const checks = useMemo(() => getPasswordChecks(password, passwordPolicy), [password, passwordPolicy]);
|
||||
const strength = checks.length === 0 ? 0 : Math.round((checks.filter((c) => c.valid).length / checks.length) * 100);
|
||||
|
||||
// S03 "E-Mail bestaetigen" — Davids Status-Card.
|
||||
if (verificationEmailSent) {
|
||||
return (
|
||||
<AuthStatus
|
||||
icon={<FeatherMail />}
|
||||
tone="positive"
|
||||
title={t("account.verify.title")}
|
||||
message={t("account.verify.emailSent")}
|
||||
dataUiId="ui.auth.register.verificationSent"
|
||||
<div
|
||||
className="flex min-h-screen w-full flex-col items-center justify-center gap-8 bg-surface-neutral-primary px-4 py-12 mobile:gap-6 mobile:py-6"
|
||||
data-ui-id="ui.auth.register.verificationSent"
|
||||
>
|
||||
<Link to="/login" className="no-underline">
|
||||
<LinkButton size="small">{t("account.login.backToLogin")}</LinkButton>
|
||||
</Link>
|
||||
</AuthStatus>
|
||||
<Logo size="64" />
|
||||
<Card size="large" variant="default" className="max-w-[448px]">
|
||||
<div className="flex w-full flex-col items-center gap-5">
|
||||
<IconWithBackground variant="information" size="large" round={true} icon={<FeatherMailCheck />} />
|
||||
<div className="flex w-full flex-col items-center gap-2">
|
||||
<span className="text-heading- font-heading- text-text-neutral-primary text-center">{t("account.verify.confirmEmailTitle")}</span>
|
||||
<span className="w-full text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary text-center">
|
||||
{t("account.verify.confirmEmailBody")}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex w-full flex-col items-center gap-2 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-3">
|
||||
<span className="text-body-extra-small-medium-150 font-body-extra-small-medium-150 text-text-neutral-tertiary">{t("account.verify.linkSentTo")}</span>
|
||||
<span className="w-full text-body-default-semibold-0 font-body-default-semibold-0 text-text-neutral-primary text-center" data-ui-id="ui.auth.register.sentEmail">
|
||||
{email}
|
||||
</span>
|
||||
</div>
|
||||
<Alert variant="neutral" notDismissible={true} title="" description={t("account.verify.checkInboxHint")} />
|
||||
<div className="flex w-full flex-col items-center gap-3">
|
||||
{/* Resend: echtes Re-Send ist backend-seitig offen (recreateToken:true) -> Intent posten + Flag. */}
|
||||
<Form method="post" className="w-full">
|
||||
<input type="hidden" name="csrf" value={csrf} readOnly />
|
||||
<input type="hidden" name="redirectTo" value={redirect} readOnly />
|
||||
<input type="hidden" name="intent" value="resendVerification" readOnly />
|
||||
<input type="hidden" name="email" value={email} readOnly />
|
||||
<input type="hidden" name="company" value={company} readOnly />
|
||||
<input type="hidden" name="first-name" value={firstName} readOnly />
|
||||
<input type="hidden" name="last-name" value={lastName} readOnly />
|
||||
{leadConversion ? (
|
||||
<>
|
||||
<input type="hidden" name="leadId" value={leadConversion.leadId} readOnly />
|
||||
<input type="hidden" name="leadToken" value={leadConversion.token} readOnly />
|
||||
{leadConversion.planId ? <input type="hidden" name="leadPlanId" value={leadConversion.planId} readOnly /> : null}
|
||||
</>
|
||||
) : null}
|
||||
<Button
|
||||
type="submit"
|
||||
className="h-10 w-full flex-none"
|
||||
icon={<FeatherRotateCw />}
|
||||
loading={isSubmitting}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.register.resend"
|
||||
>
|
||||
{t("account.register.resendEmail")}
|
||||
</Button>
|
||||
</Form>
|
||||
<Button
|
||||
className="h-10 w-full flex-none"
|
||||
variant="secondary"
|
||||
icon={<FeatherPencil />}
|
||||
onClick={() => navigate("/signup")}
|
||||
data-ui-id="ui.auth.register.changeEmail"
|
||||
>
|
||||
{t("account.verify.changeEmail")}
|
||||
</Button>
|
||||
</div>
|
||||
<div className="flex w-full items-center justify-center gap-1 px-2">
|
||||
<Link to="/login" className="no-underline" data-ui-id="ui.auth.register.toLogin">
|
||||
<LinkButton size="small" icon={<FeatherArrowLeft />}>
|
||||
{t("account.verify.toLogin")}
|
||||
</LinkButton>
|
||||
</Link>
|
||||
</div>
|
||||
</Card>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary text-center max-w-[400px]">
|
||||
{t("account.verify.linkValidityNote")}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// S01 "Signup".
|
||||
return (
|
||||
<AuthShell
|
||||
title={t("account.register.title")}
|
||||
subtitle={t("account.register.subtitle")}
|
||||
cardClassName="max-w-[480px] gap-5 shadow-lg"
|
||||
subtitle={t("account.register.signupSubtitle")}
|
||||
dataUiId="ui.auth.register.page"
|
||||
footer={
|
||||
<>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("account.register.haveAccount")}
|
||||
</span>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{t("account.register.haveAccount")}</span>
|
||||
<Link to="/login" className="no-underline" data-ui-id="ui.auth.register.login">
|
||||
<LinkButton size="small" hideIcon>
|
||||
{t("account.register.signIn")}
|
||||
@@ -92,7 +174,7 @@ export default function RegisterScreen({
|
||||
}
|
||||
>
|
||||
{appConfiguration.auth.authMethods.emailPassword.enabled ? (
|
||||
<Form method="post" noValidate className="flex w-full flex-col gap-5" data-ui-id="ui.auth.register.form">
|
||||
<Form method="post" noValidate className="flex w-full flex-col gap-4" data-ui-id="ui.auth.register.form">
|
||||
<input type="hidden" name="redirectTo" value={redirect} readOnly />
|
||||
<input type="hidden" name="csrf" value={csrf} readOnly />
|
||||
{leadConversion ? (
|
||||
@@ -103,124 +185,145 @@ export default function RegisterScreen({
|
||||
</>
|
||||
) : null}
|
||||
|
||||
{/* Davids Felder-Gruppe: alle Inputs in einem gap-4-Wrapper; Form-gap-5 trennt Gruppe/Consent/Button. */}
|
||||
{/* Davids Felder-Gruppe (gap-4). */}
|
||||
<div className="flex w-full flex-col items-start gap-4">
|
||||
<TextInput className="h-auto w-full flex-none" fillContainer showLabel label={t("account.shared.email")} type="email">
|
||||
<TextInput.Input
|
||||
name="email"
|
||||
type="email"
|
||||
required
|
||||
autoComplete="email"
|
||||
placeholder={t("account.shared.emailPlaceholder")}
|
||||
defaultValue={data.email}
|
||||
readOnly={Boolean(leadConversion)}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.register.email"
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput className="h-auto w-full flex-none" fillContainer showLabel label={t("account.shared.email")} type="email">
|
||||
<TextInput.Input
|
||||
name="email"
|
||||
type="email"
|
||||
required
|
||||
autoComplete="email"
|
||||
placeholder={t("account.shared.emailPlaceholder")}
|
||||
value={email}
|
||||
onChange={(event) => setEmail(event.target.value)}
|
||||
readOnly={Boolean(leadConversion)}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.register.email"
|
||||
/>
|
||||
</TextInput>
|
||||
|
||||
{showPasswordInput ? (
|
||||
<>
|
||||
{showPasswordInput ? (
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
<div className="flex w-full items-end gap-2">
|
||||
<TextInput className="h-auto grow shrink-0 basis-0" fillContainer showLabel label={t("account.shared.password")} type="password">
|
||||
<TextInput.Input
|
||||
name="password"
|
||||
type="password"
|
||||
required
|
||||
autoComplete="new-password"
|
||||
placeholder={t("account.shared.password")}
|
||||
value={password}
|
||||
onChange={(event) => setPassword(event.target.value)}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.register.password"
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
<TextInput className="h-auto w-full flex-none" fillContainer showLabel label={t("account.shared.password")} type="password">
|
||||
<TextInput.Input
|
||||
name="password"
|
||||
type="password"
|
||||
required
|
||||
autoComplete="new-password"
|
||||
placeholder={t("account.register.passwordChoosePlaceholder")}
|
||||
value={password}
|
||||
onChange={(event) => setPassword(event.target.value)}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.register.password"
|
||||
/>
|
||||
</TextInput>
|
||||
{passwordPolicy ? (
|
||||
<>
|
||||
<Progress className="h-auto w-full flex-none" hideLabel value={strength} />
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">
|
||||
{t("account.register.passwordStrength")}
|
||||
</span>
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">{t("account.register.passwordStrength")}</span>
|
||||
<span className="w-full text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{t("account.register.passwordHint")}</span>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
{passwordPolicy ? (
|
||||
<span className="w-full text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("account.register.passwordHint")}
|
||||
</span>
|
||||
) : null}
|
||||
</>
|
||||
) : null}
|
||||
|
||||
<div className="flex w-full items-start gap-4 mobile:flex-col">
|
||||
<TextInput className="h-auto grow shrink-0 basis-0" showLabel label={t("models.user.firstName")}>
|
||||
<TextInput.Input
|
||||
name="first-name"
|
||||
placeholder={t("account.shared.firstNamePlaceholder")}
|
||||
value={firstName}
|
||||
onChange={(event) => setFirstName(event.target.value)}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.register.firstName"
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput className="h-auto grow shrink-0 basis-0" showLabel label={t("models.user.lastName")}>
|
||||
<TextInput.Input
|
||||
name="last-name"
|
||||
placeholder={t("account.shared.lastNamePlaceholder")}
|
||||
value={lastName}
|
||||
onChange={(event) => setLastName(event.target.value)}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.register.lastName"
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
|
||||
<TextInput
|
||||
className="h-auto w-full flex-none"
|
||||
fillContainer
|
||||
showLabel
|
||||
label={t("account.register.companyLabel")}
|
||||
icon={<FeatherBuilding />}
|
||||
>
|
||||
<TextInput.Input
|
||||
name="company"
|
||||
required={appConfiguration.auth.requireOrganization}
|
||||
placeholder={t("account.register.companyPlaceholder")}
|
||||
value={company}
|
||||
onChange={(event) => setCompany(event.target.value)}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.register.company"
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
|
||||
{/* Sicherheitspruefung — Davids Box mit echtem mCaptcha-Widget statt statischer Mock-Checkbox. */}
|
||||
{captchaEnabled ? (
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
<span className="text-body-extra-small-semibold-0 font-body-extra-small-semibold-0 uppercase text-text-neutral-tertiary">
|
||||
{t("account.register.securityCheck")}
|
||||
</span>
|
||||
<div className="flex w-full items-center justify-center rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-3">
|
||||
<Captcha
|
||||
enabled
|
||||
provider={appConfiguration.auth.captcha.provider}
|
||||
instanceUrl={appConfiguration.auth.captcha.instanceUrl}
|
||||
sitekey={appConfiguration.auth.captcha.loginSiteKey}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<TextInput className="h-auto w-full flex-none" fillContainer showLabel label={t("account.register.companyLabel")}>
|
||||
<TextInput.Input
|
||||
name="company"
|
||||
required={appConfiguration.auth.requireOrganization}
|
||||
placeholder={t("account.shared.companyPlaceholder")}
|
||||
defaultValue={data.company}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.register.company"
|
||||
/>
|
||||
</TextInput>
|
||||
|
||||
<div className="flex w-full items-start gap-4 mobile:flex-col">
|
||||
<TextInput className="h-auto grow shrink-0 basis-0" showLabel label={t("models.user.firstName")}>
|
||||
<TextInput.Input
|
||||
name="first-name"
|
||||
placeholder={t("account.shared.firstNamePlaceholder")}
|
||||
defaultValue={data.firstName}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.register.firstName"
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput className="h-auto grow shrink-0 basis-0" showLabel label={t("models.user.lastName")}>
|
||||
<TextInput.Input
|
||||
name="last-name"
|
||||
placeholder={t("account.shared.lastNamePlaceholder")}
|
||||
defaultValue={data.lastName}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.register.lastName"
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
|
||||
<TextInput className="h-auto w-full flex-none" fillContainer showLabel label={t("account.register.phone")} type="tel">
|
||||
<TextInput.Input
|
||||
name="phone"
|
||||
type="tel"
|
||||
placeholder={t("account.register.phonePlaceholder")}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.register.phone"
|
||||
/>
|
||||
</TextInput>
|
||||
|
||||
<TextInput className="h-auto w-full flex-none" fillContainer showLabel label={t("account.register.vatId")}>
|
||||
<TextInput.Input
|
||||
name="vatNumber"
|
||||
placeholder={t("account.register.vatIdPlaceholder")}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.register.vat"
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
|
||||
{/* Consents — Davids 2 Checkboxen mit Prefix + Link. */}
|
||||
<div className="flex w-full flex-col items-start gap-3">
|
||||
<Checkbox label={t("account.register.consentTerms")} checked={acceptTerms} onCheckedChange={setAcceptTerms} />
|
||||
<Checkbox label={t("account.register.consentPrivacy")} checked={acceptPrivacy} onCheckedChange={setAcceptPrivacy} />
|
||||
<Checkbox label={t("account.register.consentDpa")} checked={acceptDpa} onCheckedChange={setAcceptDpa} />
|
||||
<div className="flex w-full items-center gap-2">
|
||||
<Checkbox label={t("account.register.consentTerms")} hideLabel checked={acceptTerms} onCheckedChange={setAcceptTerms} data-ui-id="ui.auth.register.consentTerms" />
|
||||
<div className="flex min-h-5 flex-wrap items-center gap-1">
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">{t("account.register.consentAcceptPrefix")}</span>
|
||||
<a href="/terms-and-conditions" target="_blank" rel="noreferrer" className="no-underline">
|
||||
<LinkButton size="small" hideIcon>
|
||||
{t("account.register.consentTermsLink")}
|
||||
</LinkButton>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex w-full items-center gap-2">
|
||||
<Checkbox label={t("account.register.consentPrivacy")} hideLabel checked={acceptPrivacy} onCheckedChange={setAcceptPrivacy} data-ui-id="ui.auth.register.consentPrivacy" />
|
||||
<div className="flex min-h-5 flex-wrap items-center gap-1">
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">{t("account.register.consentAcceptPrefix")}</span>
|
||||
<a href="/privacy-policy" target="_blank" rel="noreferrer" className="no-underline">
|
||||
<LinkButton size="small" hideIcon>
|
||||
{t("account.register.privacyPolicy")}
|
||||
</LinkButton>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Captcha
|
||||
enabled={requireCaptcha && appConfiguration.auth.captcha.enabled}
|
||||
instanceUrl={appConfiguration.auth.captcha.instanceUrl}
|
||||
sitekey={appConfiguration.auth.captcha.loginSiteKey}
|
||||
/>
|
||||
|
||||
<Button type="submit" loading={isSubmitting} disabled={isSubmitting || !allConsents} data-ui-id="ui.auth.register.submit">
|
||||
{t("account.register.title")}
|
||||
</Button>
|
||||
{/* Button-Gruppe — Submit + Bestaetigungs-Mail-Hinweis (nur wenn verifiziert wird). */}
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
<Button type="submit" className="h-9 w-full flex-none" loading={isSubmitting} disabled={isSubmitting || !allConsents} data-ui-id="ui.auth.register.submit">
|
||||
{t("account.register.title")}
|
||||
</Button>
|
||||
{requireEmailVerification ? (
|
||||
<div className="flex w-full items-center justify-center gap-1">
|
||||
<FeatherMail className="text-body-small-regular-0 font-body-small-regular-0 text-icon-neutral-tertiary" />
|
||||
<span className="text-body-extra-small-regular-0 font-body-extra-small-regular-0 text-text-neutral-tertiary">{t("account.register.confirmationEmailNote")}</span>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{error && navigation.state === "idle" ? (
|
||||
<p className="text-center text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-negative" role="alert">
|
||||
|
||||
+16
-5
@@ -1,7 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { Form, useLocation, useNavigate, useNavigation } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherAlertTriangle, FeatherCheck } from "@subframe/core";
|
||||
import { FeatherArrowLeft, FeatherCheck, FeatherRotateCw, FeatherUnlink2 } from "@subframe/core";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import { AuthShell, AuthStatus } from "~/components/auth/AuthShell";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
@@ -55,20 +55,31 @@ export default function ResetPasswordScreen({
|
||||
);
|
||||
}
|
||||
|
||||
// Kein/ungueltiger Link (keine E-Mail im e-Param) -> Davids "Reset Link _ Invalid".
|
||||
// Kein/ungueltiger Link (keine E-Mail im e-Param) -> Davids WF-P2 "V01 Reset-Link ungueltig".
|
||||
if (!data.email) {
|
||||
return (
|
||||
<AuthStatus
|
||||
icon={<FeatherAlertTriangle />}
|
||||
icon={<FeatherUnlink2 />}
|
||||
tone="negative"
|
||||
title={t("account.newPassword.invalidTitle")}
|
||||
message={t("account.newPassword.invalidBody")}
|
||||
dataUiId="ui.auth.reset.invalid"
|
||||
>
|
||||
<Button onClick={() => navigate("/forgot-password")} data-ui-id="ui.auth.reset.requestNew">
|
||||
<Button
|
||||
className="h-9 w-full flex-none"
|
||||
icon={<FeatherRotateCw />}
|
||||
onClick={() => navigate("/forgot-password")}
|
||||
data-ui-id="ui.auth.reset.requestNew"
|
||||
>
|
||||
{t("account.newPassword.requestNew")}
|
||||
</Button>
|
||||
<LinkButton size="small" hideIcon onClick={() => navigate("/login")} data-ui-id="ui.auth.reset.invalidBackToLogin">
|
||||
<LinkButton
|
||||
size="small"
|
||||
icon={<FeatherArrowLeft />}
|
||||
iconRight={null}
|
||||
onClick={() => navigate("/login")}
|
||||
data-ui-id="ui.auth.reset.invalidBackToLogin"
|
||||
>
|
||||
{t("account.forgot.backToLogin")}
|
||||
</LinkButton>
|
||||
</AuthStatus>
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { Fragment, useState } from "react";
|
||||
import { Form, useNavigation } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherAlertTriangle, FeatherLogOut, FeatherMonitor, FeatherShieldOff, FeatherSmartphone } from "@subframe/core";
|
||||
import type { SessionListVM } from "@toolctrl/view-models";
|
||||
import type { SessionListVM } from "@hivegrid/view-models";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
|
||||
|
||||
+198
@@ -0,0 +1,198 @@
|
||||
import { useState } from "react";
|
||||
import { Form, Link, useNavigate, useNavigation } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherArrowLeft, FeatherCheckCircle, FeatherShieldCheck, FeatherWand2 } from "@subframe/core";
|
||||
import { AuthShell, AuthStatus } from "~/components/auth/AuthShell";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { LinkButton } from "~/ui/components/LinkButton";
|
||||
import { Progress } from "~/ui/components/Progress";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
// Set-Password-Screen (WF-P2 / S01 "Neues Passwort setzen") nach Davids Subframe-Design: Card mit
|
||||
// "Neues Passwort festlegen" + Stärke-Anzeige + Bestätigung + "Passwort setzen", Sicherheits-Footer.
|
||||
// An die bestehende Einladungs-Action verdrahtet (intent=set-password / intent=magic-link) — Feldnamen
|
||||
// (password, password-confirm) + Branches (Neu-Nutzer / Bestands-Nutzer / angenommen) unverändert, nur
|
||||
// re-skinned auf Davids Auth-Optik (AuthShell/AuthStatus, ~/ui). Token-Drift vermieden über die Card.
|
||||
//
|
||||
// Bewusste, dokumentierte Abweichungen ggü. Davids reinem S01-Mock (Funktionalität erhalten):
|
||||
// - Magic-Link-Überspringen ("intent=magic-link") bleibt als Sekundär-Aktion erhalten (nur Neu-Nutzer).
|
||||
// - Einladungs-Kontext (eingeladen zu Tenant X, E-Mail) wird als Kopfzeile gezeigt.
|
||||
// - PasswordStrengthIndicator existiert nicht im Code -> Progress + Stärke-Label (wie ResetPasswordScreen).
|
||||
|
||||
type SetPasswordInvitation = {
|
||||
pending?: boolean;
|
||||
email: string;
|
||||
firstName?: string | null;
|
||||
tenant: { name: string };
|
||||
};
|
||||
|
||||
function passwordStrength(pw: string): number {
|
||||
if (!pw) return 0;
|
||||
const checks = [pw.length >= 8, /[A-Z]/.test(pw), /[a-z]/.test(pw), /\d/.test(pw), /[^A-Za-z0-9]/.test(pw)];
|
||||
return Math.round((checks.filter(Boolean).length / checks.length) * 100);
|
||||
}
|
||||
|
||||
export default function SetPasswordScreen({
|
||||
data,
|
||||
actionData,
|
||||
}: {
|
||||
data: { invitation: SetPasswordInvitation | null; existingUser: { id: string } | null; appRootPath: string };
|
||||
actionData: { error?: string; invitationAccepted?: boolean } | null | undefined;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const navigation = useNavigation();
|
||||
const navigate = useNavigate();
|
||||
const isSubmitting = navigation.state !== "idle";
|
||||
const [password, setPassword] = useState("");
|
||||
const strength = passwordStrength(password);
|
||||
const strengthLabel =
|
||||
strength < 40 ? t("account.newPassword.strengthWeak") : strength < 80 ? t("account.newPassword.strengthMedium") : t("account.newPassword.strengthStrong");
|
||||
|
||||
const { invitation, existingUser } = data;
|
||||
|
||||
// Einladung angenommen oder nicht (mehr) offen -> Davids Erfolgs-Status (1:1 zur bisherigen Logik).
|
||||
if (!invitation?.pending || actionData?.invitationAccepted) {
|
||||
return (
|
||||
<AuthStatus
|
||||
icon={<FeatherCheckCircle />}
|
||||
tone="positive"
|
||||
title={t("auth:invitation.accepted.title")}
|
||||
message={t("auth:invitation.accepted.description")}
|
||||
dataUiId="ui.auth.setPassword.accepted"
|
||||
>
|
||||
<Link to={data.appRootPath} className="no-underline" data-ui-id="ui.auth.setPassword.acceptedSignIn">
|
||||
<LinkButton size="small" hideIcon>
|
||||
{t("account.shared.signIn")}
|
||||
</LinkButton>
|
||||
</Link>
|
||||
</AuthStatus>
|
||||
);
|
||||
}
|
||||
|
||||
const invitedName = invitation.firstName ? invitation.firstName : invitation.email;
|
||||
|
||||
// Bestands-Nutzer: kein Passwort setzen, nur Einladung annehmen.
|
||||
if (existingUser) {
|
||||
return (
|
||||
<AuthShell
|
||||
title={t("auth:invitation.accepted.title")}
|
||||
subtitle={`${t("shared.hi")} ${invitedName}, ${t("account.invitation.youWereInvited")} ${invitation.tenant.name}`}
|
||||
titleAlign="center"
|
||||
headerGap="gap-1.5"
|
||||
subtitleVariant="regular-150"
|
||||
cardSize="large"
|
||||
showLogo={true}
|
||||
dataUiId="ui.auth.setPassword.existingUser"
|
||||
>
|
||||
<Form method="post" className="flex w-full flex-col gap-4" data-ui-id="ui.auth.setPassword.acceptForm">
|
||||
<Button type="submit" name="intent" value="set-password" className="h-9 w-full flex-none" loading={isSubmitting} disabled={isSubmitting} data-ui-id="ui.auth.setPassword.acceptSubmit">
|
||||
{t("account.invitation.button")}
|
||||
</Button>
|
||||
{actionData?.error && 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}
|
||||
</p>
|
||||
) : null}
|
||||
</Form>
|
||||
<div className="flex w-full items-center justify-center">
|
||||
<LinkButton size="small" icon={<FeatherArrowLeft />} onClick={() => navigate("/login")} data-ui-id="ui.auth.setPassword.existingBackToLogin">
|
||||
{t("account.forgot.backToLogin")}
|
||||
</LinkButton>
|
||||
</div>
|
||||
</AuthShell>
|
||||
);
|
||||
}
|
||||
|
||||
// Neu-Nutzer: Davids S01 "Neues Passwort setzen".
|
||||
return (
|
||||
<AuthShell
|
||||
title={t("account.newPassword.title")}
|
||||
subtitle={t("account.setPassword.subtitle")}
|
||||
titleAlign="center"
|
||||
headerGap="gap-1.5"
|
||||
subtitleVariant="regular-150"
|
||||
cardSize="large"
|
||||
showLogo={true}
|
||||
dataUiId="ui.auth.setPassword.page"
|
||||
footer={
|
||||
<div className="flex w-full items-center justify-center gap-1.5 text-center">
|
||||
<FeatherShieldCheck className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-subtle" />
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("account.setPassword.secureConnection")}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<span className="w-full text-center text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary" data-ui-id="ui.auth.setPassword.invitedContext">
|
||||
{`${t("shared.hi")} ${invitedName}, ${t("account.invitation.youWereInvited")} ${invitation.tenant.name}`}
|
||||
</span>
|
||||
|
||||
<Form id="setPasswordForm" method="post" noValidate className="flex w-full flex-col gap-5" data-ui-id="ui.auth.setPassword.form">
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
<TextInput className="h-auto w-full flex-none" fillContainer showLabel label={t("account.newPassword.passwordLabel")} type="password">
|
||||
<TextInput.Input
|
||||
name="password"
|
||||
type="password"
|
||||
required
|
||||
autoFocus
|
||||
autoComplete="new-password"
|
||||
placeholder={t("account.setPassword.passwordPlaceholder")}
|
||||
value={password}
|
||||
onChange={(event) => setPassword(event.target.value)}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.setPassword.password"
|
||||
/>
|
||||
</TextInput>
|
||||
<Progress className="h-auto w-full flex-none" hideLabel value={strength} state={strength >= 80 ? "success" : undefined} />
|
||||
<span className="text-body-extra-small-regular-0 font-body-extra-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("account.register.passwordStrength")}: {strengthLabel}
|
||||
</span>
|
||||
<span className="w-full text-body-extra-small-medium-150 font-body-extra-small-medium-150 text-text-neutral-tertiary">
|
||||
{t("account.setPassword.passwordHint")}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<TextInput className="h-auto w-full flex-none" fillContainer showLabel label={t("account.register.confirmPassword")} type="password">
|
||||
<TextInput.Input
|
||||
name="password-confirm"
|
||||
type="password"
|
||||
required
|
||||
autoComplete="new-password"
|
||||
placeholder={t("account.setPassword.confirmPlaceholder")}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.setPassword.passwordConfirm"
|
||||
/>
|
||||
</TextInput>
|
||||
|
||||
<Button type="submit" name="intent" value="set-password" className="h-9 w-full flex-none" loading={isSubmitting} disabled={isSubmitting} data-ui-id="ui.auth.setPassword.submit">
|
||||
{t("account.setPassword.button")}
|
||||
</Button>
|
||||
|
||||
{actionData?.error && 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}
|
||||
</p>
|
||||
) : null}
|
||||
</Form>
|
||||
|
||||
<div className="flex w-full flex-col items-center gap-3">
|
||||
<Button
|
||||
type="submit"
|
||||
form="setPasswordForm"
|
||||
name="intent"
|
||||
value="magic-link"
|
||||
variant="tertiary"
|
||||
icon={<FeatherWand2 />}
|
||||
loading={isSubmitting}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.setPassword.magicLink"
|
||||
>
|
||||
{t("auth:invitation.skipPasswordUseMagicLink")}
|
||||
</Button>
|
||||
<LinkButton size="small" icon={<FeatherArrowLeft />} onClick={() => navigate("/login")} data-ui-id="ui.auth.setPassword.backToLogin">
|
||||
{t("account.forgot.backToLogin")}
|
||||
</LinkButton>
|
||||
</div>
|
||||
</AuthShell>
|
||||
);
|
||||
}
|
||||
+40
-53
@@ -1,38 +1,37 @@
|
||||
import { useSubmit, Link } from "react-router";
|
||||
import { useSubmit } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type Stripe from "stripe";
|
||||
import { PlanFeatureUsageDto } from "~/application/dtos/subscriptions/PlanFeatureUsageDto";
|
||||
import MyBillingSession from "~/components/core/settings/subscription/MyBillingSession";
|
||||
import MyInvoices from "~/components/core/settings/subscription/MyInvoices";
|
||||
import MyPayments from "~/components/core/settings/subscription/MyPayments";
|
||||
import MyProducts from "~/components/core/settings/subscription/MyProducts";
|
||||
import MySubscriptionFeatures from "~/components/core/settings/subscription/MySubscriptionFeatures";
|
||||
import MyUpcomingInvoice from "~/components/core/settings/subscription/MyUpcomingInvoice";
|
||||
import MyInvoices from "~/components/core/settings/subscription/MyInvoices";
|
||||
import SettingSection from "~/components/ui/sections/SettingSection";
|
||||
import { TenantSubscriptionProductWithDetails } from "~/utils/db/subscriptions/tenantSubscriptionProducts.db.server";
|
||||
import { TenantSubscriptionWithDetails } from "~/utils/db/tenantSubscriptions.db.server";
|
||||
import { TenantSimple } from "~/utils/db/tenants.db.server";
|
||||
import { subscriptionCheckoutPath } from "~/utils/app/SubscriptionUrlUtils";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import type { CustomerBillingInvoiceDto } from "~/application/dtos/billing/CustomerBillingInvoiceDto";
|
||||
import type { SubscriptionProductDto } from "~/application/dtos/subscriptions/SubscriptionProductDto";
|
||||
import type { SubscriptionBillingPeriod } from "~/application/enums/subscriptions/SubscriptionBillingPeriod";
|
||||
import PlansGrouped from "~/components/core/settings/subscription/plans/PlansGrouped";
|
||||
|
||||
export default function SubscriptionSettings({
|
||||
currentTenant,
|
||||
mySubscription,
|
||||
myInvoices,
|
||||
myPayments,
|
||||
myFeatures,
|
||||
myUpcomingInvoices,
|
||||
myInvoices,
|
||||
availablePlans,
|
||||
currenciesAndPeriod,
|
||||
invoiceErrorKey,
|
||||
permissions,
|
||||
}: {
|
||||
currentTenant: TenantSimple;
|
||||
mySubscription: TenantSubscriptionWithDetails | null;
|
||||
myInvoices: Stripe.Invoice[];
|
||||
myPayments: Stripe.PaymentIntent[];
|
||||
myFeatures: PlanFeatureUsageDto[];
|
||||
myUpcomingInvoices: Stripe.Invoice[];
|
||||
permissions: {
|
||||
viewInvoices: boolean;
|
||||
myInvoices: CustomerBillingInvoiceDto[];
|
||||
availablePlans: SubscriptionProductDto[];
|
||||
currenciesAndPeriod: {
|
||||
currencies: { value: string; options: string[] };
|
||||
billingPeriods: { value: SubscriptionBillingPeriod; options: SubscriptionBillingPeriod[] };
|
||||
};
|
||||
invoiceErrorKey?: string | null;
|
||||
permissions: { viewInvoices: boolean; manageSubscription: boolean };
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const submit = useSubmit();
|
||||
@@ -56,15 +55,6 @@ export default function SubscriptionSettings({
|
||||
// });
|
||||
// }
|
||||
|
||||
function onOpenCustomerPortal() {
|
||||
const form = new FormData();
|
||||
form.set("action", "open-customer-portal");
|
||||
form.set("csrf", csrf ?? "");
|
||||
submit(form, {
|
||||
method: "post",
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4" data-ui-id="ui.subscription.page">
|
||||
<SettingSection
|
||||
@@ -72,20 +62,33 @@ export default function SubscriptionSettings({
|
||||
description={
|
||||
<div className="flex flex-col space-y-1">
|
||||
<div>{t("settings.subscription.description")}</div>
|
||||
<div>
|
||||
{mySubscription?.products && mySubscription.products.length > 0 && (
|
||||
<Link to={subscriptionCheckoutPath(currentTenant.slug)} className="text-theme-600 underline" data-ui-id="ui.subscription.checkout.link">
|
||||
{t("settings.subscription.viewAllProducts")}
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
className=""
|
||||
>
|
||||
<MyProducts currentTenant={currentTenant} items={mySubscription?.products ?? []} onCancel={onCancel} />
|
||||
<MyProducts items={mySubscription?.products ?? []} onCancel={onCancel} />
|
||||
</SettingSection>
|
||||
|
||||
{availablePlans.length > 0 && (
|
||||
<>
|
||||
<div className="hidden sm:block" aria-hidden="true">
|
||||
<div className="py-4">
|
||||
<div className="border-border border-t"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<SettingSection title={t("settings.subscription.checkout.plans.title")} description={t("settings.subscription.checkout.plans.description")} className="">
|
||||
<PlansGrouped
|
||||
items={availablePlans}
|
||||
tenantSubscription={mySubscription}
|
||||
canSubmit={permissions.manageSubscription}
|
||||
billingProviderCoupon={null}
|
||||
currenciesAndPeriod={currenciesAndPeriod}
|
||||
/>
|
||||
</SettingSection>
|
||||
</>
|
||||
)}
|
||||
|
||||
{myFeatures.length > 0 && (
|
||||
<>
|
||||
<div className="hidden sm:block" aria-hidden="true">
|
||||
@@ -108,33 +111,17 @@ export default function SubscriptionSettings({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<SettingSection title={t("app.subscription.invoices.title")} description={t("app.subscription.invoices.description")}>
|
||||
<div className="space-y-2">
|
||||
<MyUpcomingInvoice items={myUpcomingInvoices} />
|
||||
<MyInvoices items={myInvoices} />
|
||||
<MyPayments items={myPayments} />
|
||||
</div>
|
||||
<SettingSection title={t("app.subscription.invoices.title")} description={t("app.subscription.invoices.description")} className="">
|
||||
<MyInvoices items={myInvoices} error={invoiceErrorKey ? t(invoiceErrorKey) : null} />
|
||||
</SettingSection>
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className="hidden sm:block" aria-hidden="true">
|
||||
<div className="py-4">
|
||||
<div className="border-border border-t"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* <SettingSection title={t("app.subscription.paymentMethods.title")} description={t("app.subscription.paymentMethods.description")}>
|
||||
<div className="space-y-2">
|
||||
<MyPaymentMethods items={myPaymentMethods} onAdd={onAddPaymentMethod} onDelete={onDeletePaymentMethod} />
|
||||
</div>
|
||||
</SettingSection> */}
|
||||
|
||||
<SettingSection title={t("app.subscription.billing.title")} description={t("app.subscription.billing.description")}>
|
||||
<div className="space-y-2">
|
||||
<MyBillingSession onClick={onOpenCustomerPortal} />
|
||||
</div>
|
||||
</SettingSection>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+3
-3
@@ -127,7 +127,7 @@ function expectNoSecretsLeak() {
|
||||
expect(serialized).not.toContain("totpSecretEncrypted");
|
||||
expect(serialized).not.toContain("hash-1");
|
||||
expect(serialized).not.toContain("hash-2");
|
||||
expect(serialized).not.toContain("RJ_session");
|
||||
expect(serialized).not.toContain("hivegrid_session");
|
||||
expect(serialized).not.toContain("raw-cookie-value");
|
||||
expect(serialized).not.toContain("csrf-secret");
|
||||
expect(serialized).not.toContain("new-password-value");
|
||||
@@ -178,13 +178,13 @@ describe("UserProfileSettings", () => {
|
||||
user={baseUser}
|
||||
currentSession={currentSession}
|
||||
mfaStatus={{ enabled: false, pending: true, enabledAt: null, pendingCreatedAt: "2026-05-08T12:00:00.000Z" }}
|
||||
otpauthUri="otpauth://totp/ToolCTRL:ada@example.com?issuer=ToolCTRL"
|
||||
otpauthUri="otpauth://totp/HiveGrid:ada@example.com?issuer=HiveGrid"
|
||||
mfaError="Enter the 6-digit authenticator code."
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByText("settings.profile.mfa.status.pending")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("Authenticator setup URI")).toHaveTextContent("otpauth://totp/ToolCTRL:ada@example.com?issuer=ToolCTRL");
|
||||
expect(screen.getByLabelText("Authenticator setup URI")).toHaveTextContent("otpauth://totp/HiveGrid:ada@example.com?issuer=HiveGrid");
|
||||
expect(screen.getByRole("alert")).toHaveTextContent("Enter the 6-digit authenticator code.");
|
||||
expect(screen.getByLabelText("Authenticator code")).toHaveAttribute("name", "code");
|
||||
expect(screen.getByRole("button", { name: "Confirm authenticator" })).toBeInTheDocument();
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ function getLightOrDarkModeLabel(t: TFunction, value?: string | null) {
|
||||
if (value === "light" || value === "dark") {
|
||||
return t(`shared.${value}`);
|
||||
}
|
||||
return value || t("settings.profile.session.systemPreference");
|
||||
return t("shared.light");
|
||||
}
|
||||
|
||||
function getMfaStepUpLabel(t: TFunction, mfaStepUp?: CurrentSessionSettings["mfaStepUp"]) {
|
||||
@@ -447,7 +447,7 @@ export default function UserProfileSettings({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<SettingSection title={t("settings.danger.title")} description={t("settings.danger.description")}>
|
||||
<SettingSection title={t("settings.danger.title")} description={t("settings.danger.description")} tone="danger">
|
||||
{/*Danger */}
|
||||
<div className="mt-12 md:col-span-2 md:mt-0">
|
||||
<div>
|
||||
|
||||
Reference in new issue
Block a user