Skip to content

Commit 06669c1

Browse files
committed
feat(shadcn): Add secret key to TOTP enrollment
1 parent f881f22 commit 06669c1

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

packages/shadcn/src/components/totp-multi-factor-enrollment-form.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ describe("<TotpMultiFactorEnrollmentForm />", () => {
107107
expect(screen.getByTestId("input-otp-slot-0")).toBeInTheDocument();
108108
});
109109

110+
expect(screen.getByRole("img", { name: "TOTP QR Code" })).toBeInTheDocument();
111+
expect(screen.getByText("test-secret")).toBeInTheDocument();
110112
expect(screen.getByText("Scan this QR code with your authenticator app")).toBeInTheDocument();
111113
expect(screen.getByRole("button", { name: "Verify Code" })).toBeInTheDocument();
112114
});

packages/shadcn/src/components/totp-multi-factor-enrollment-form.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,12 @@ export function MultiFactorEnrollmentVerifyTotpForm(props: MultiFactorEnrollment
104104

105105
return (
106106
<div className="space-y-4">
107-
<div className="flex justify-center">
108-
<div className="border rounded-lg p-4">
109-
<img src={qrCodeDataUrl} alt="TOTP QR Code" className="mx-auto" />
110-
<p className="text-sm text-muted-foreground text-center mt-2">
111-
{getTranslation(ui, "prompts", "mfaTotpQrCodePrompt")}
112-
</p>
113-
</div>
107+
<div className="flex flex-col gap-y-4 items-center justify-center">
108+
<img src={qrCodeDataUrl} alt="TOTP QR Code" className="mx-auto" />
109+
<code className="text-xs text-muted-foreground text-center">{props.secret.secretKey.toString()}</code>
110+
<p className="text-xs text-muted-foreground text-center">
111+
{getTranslation(ui, "prompts", "mfaTotpQrCodePrompt")}
112+
</p>
114113
</div>
115114
<Form {...form}>
116115
<form onSubmit={form.handleSubmit(onSubmit)} className="flex flex-col gap-y-4">

0 commit comments

Comments
 (0)