Two-Factor Setup
Complete 2FA setup flow with QR code and recovery codes
Overview
TwoFactorSetup guides users through a three-step 2FA enrollment flow: scanning a QR code (or entering a secret key manually), verifying the TOTP code from their authenticator app, and saving recovery codes. It includes sub-components QrCodeDisplay, SecretKeyDisplay, and RecoveryCodesDisplay.
Usage
import { TwoFactorSetup } from "@leanicon/web-builder-library/saas";
<TwoFactorSetup
setupData={{
totpSecret: "JBSWY3DPEHPK3PXP",
otpAuthUrl: "otpauth://totp/MyApp:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=MyApp",
recoveryCodes: ["ABCD-1234", "EFGH-5678", "IJKL-9012"],
}}
onVerifyCode={async (code) => verifyTotpCode(code)}
onComplete={() => router.push("/settings")}
/>;Variants
Default
Set Up Two-Factor Authentication
Scan this QR code with your authenticator app
Can't scan? Enter this key manually:
JBSW Y3DP EHPK 3PXPWith App Name
Set Up Two-Factor Authentication
Scan this QR code with your authenticator app
Can't scan? Enter this key manually:
JBSW Y3DP EHPK 3PXPScan Step
Set Up Two-Factor Authentication
Scan this QR code with your authenticator app
Can't scan? Enter this key manually:
JBSW Y3DP EHPK 3PXPVerify Step
Set Up Two-Factor Authentication
Enter the 6-digit code from your app
Recovery Codes Step
Set Up Two-Factor Authentication
Save these recovery codes in a safe place
ABCD-1234EFGH-5678IJKL-9012MNOP-3456QRST-7890UVWX-1234YZAB-5678CDEF-9012With Error
Set Up Two-Factor Authentication
Enter the 6-digit code from your app
Loading State
Set Up Two-Factor Authentication
Scan this QR code with your authenticator app
Can't scan? Enter this key manually:
JBSW Y3DP EHPK 3PXPWith Custom Labels
Configurar Autenticacion de Dos Factores
Scan this QR code with your authenticator app
Can't scan? Enter this key manually:
JBSW Y3DP EHPK 3PXPProps
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
setupData | TwoFactorSetupData | — | Yes | |
onVerifyCode | (code: string) => Promise<boolean> | — | Yes | |
onComplete | () => void | — | Yes | |
onCancel | (() => void) | — | No | |
currentStep | enum | — | No | |
onStepChange | ((step: TwoFactorSetupStep) => void) | — | No | |
appName | string | — | No | |
userEmail | string | — | No | |
labels | TwoFactorSetupLabels | — | No | |
className | string | — | No | |
isLoading | boolean | false | No | |
error | string | — | No |