Skip to content

Commit f881f22

Browse files
committed
feat(react): Add TOTP description improve layout
1 parent 68b0c7d commit f881f22

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

packages/react/src/auth/forms/mfa/totp-multi-factor-enrollment-form.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ describe("<MultiFactorEnrollmentVerifyTotpForm />", () => {
171171
},
172172
prompts: {
173173
mfaTotpQrCodePrompt: "Scan this QR code with your authenticator app",
174+
mfaTotpEnrollmentVerificationPrompt: "Add the code generated by your authenticator app",
174175
},
175176
}),
176177
});
@@ -189,6 +190,10 @@ describe("<MultiFactorEnrollmentVerifyTotpForm />", () => {
189190

190191
expect(screen.getByRole("textbox", { name: /verificationCode/i })).toBeInTheDocument();
191192

193+
const description = container.querySelector("[data-input-description]");
194+
expect(description).toBeInTheDocument();
195+
expect(description).toHaveTextContent("Add the code generated by your authenticator app");
196+
192197
const verifyCodeButton = screen.getByRole("button", { name: "verifyCode" });
193198
expect(verifyCodeButton).toBeInTheDocument();
194199
expect(verifyCodeButton).toHaveAttribute("type", "submit");

packages/react/src/auth/forms/mfa/totp-multi-factor-enrollment-form.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,19 @@ export function MultiFactorEnrollmentVerifyTotpForm(props: MultiFactorEnrollment
155155
>
156156
<div className="fui-qr-code-container">
157157
<img src={qrCodeDataUrl} alt="TOTP QR Code" />
158+
<code>{props.secret.secretKey.toString()}</code>
158159
<p>{getTranslation(ui, "prompts", "mfaTotpQrCodePrompt")}</p>
159160
</div>
160161
<form.AppForm>
161162
<fieldset>
162163
<form.AppField name="verificationCode">
163-
{(field) => <field.Input label={getTranslation(ui, "labels", "verificationCode")} type="text" />}
164+
{(field) => (
165+
<field.Input
166+
label={getTranslation(ui, "labels", "verificationCode")}
167+
type="text"
168+
description={getTranslation(ui, "prompts", "mfaTotpEnrollmentVerificationPrompt")}
169+
/>
170+
)}
164171
</form.AppField>
165172
</fieldset>
166173
<fieldset>

packages/styles/src/base.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484

8585
:where(.fui-content) {
8686
@apply space-y-2;
87-
8887
}
8988

9089
:where(.fui-card) {
@@ -140,6 +139,10 @@
140139
@apply flex items-center gap-2;
141140
}
142141

142+
:where(.fui-form .fui-qr-code-container) {
143+
@apply flex flex-col items-center gap-4 text-text-muted text-xs;
144+
}
145+
143146
:where(.fui-error) {
144147
@apply text-error text-left text-xs;
145148
}

packages/translations/src/locales/en-us.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,6 @@ export const enUS = {
103103
mfaAssertionFactorPrompt: "Please choose a multi-factor authentication method",
104104
mfaTotpQrCodePrompt: "Scan this QR code with your authenticator app",
105105
mfaSmsEnrollmentVerificationPrompt: "Enter the verification code sent to your phone number",
106+
mfaTotpEnrollmentVerificationPrompt: "Add the code generated by your authenticator app",
106107
},
107108
} satisfies Translations;

packages/translations/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,6 @@ export type Translations = {
109109
mfaAssertionFactorPrompt?: string;
110110
mfaTotpQrCodePrompt?: string;
111111
mfaSmsEnrollmentVerificationPrompt?: string;
112+
mfaTotpEnrollmentVerificationPrompt?: string;
112113
};
113114
};

0 commit comments

Comments
 (0)