Skip to content

Documentation / react-auth / useMfaEnrollment

Function: useMfaEnrollment()

useMfaEnrollment(): Object

Use this hook to enroll a user in MFA

Returns

Object

initEnrollmentWithSms - starts the MFA enrollment flow for SMS

initEnrollmentWithTotp - starts the MFA enrollment flow for TOTP

submitEnrollmentWithSms - completes the MFA enrollment flow for SMS

submitEnrollmentWithTotp - completes the MFA enrollment flow for TOTP

unenrollWithSms - unenrolls the SMS MFA method

unenrollWithTotp - unenrolls the TOTP MFA method

showMfaEnrollmentModal - opens the MFA enrollment modal

closeMfaEnrollmentModal - closes the MFA enrollment modal

closeMfaEnrollmentModal

closeMfaEnrollmentModal: () => void

Returns

void

initEnrollmentWithPasskey

initEnrollmentWithPasskey: () => Promise<void>

Returns

Promise<void>

initEnrollmentWithSms

initEnrollmentWithSms: (meta) => Promise<void>

Parameters

meta: Object

meta.phoneNumber: string

Returns

Promise<void>

initEnrollmentWithTotp

initEnrollmentWithTotp: () => Promise<Object>

Returns

Promise<Object>

authUrl

authUrl: string

secret

secret: string

showMfaEnrollmentModal

showMfaEnrollmentModal: () => void

Returns

void

submitEnrollmentWithPasskey

submitEnrollmentWithPasskey: (meta) => Promise<void>

Parameters

meta: Object

meta.credentialIds: string[]

Returns

Promise<void>

submitEnrollmentWithSms

submitEnrollmentWithSms: (meta) => Promise<void>

Parameters

meta: Object

meta.mfaCode: string

meta.phoneNumber: string

Returns

Promise<void>

submitEnrollmentWithTotp

submitEnrollmentWithTotp: (meta) => Promise<void>

Parameters

meta: Object

meta.mfaCode: string

Returns

Promise<void>

unenrollWithPasskey

unenrollWithPasskey: () => Promise<void>

Returns

Promise<void>

unenrollWithSms

unenrollWithSms: () => Promise<void>

Returns

Promise<void>

unenrollWithTotp

unenrollWithTotp: () => Promise<void>

Returns

Promise<void>

Example

ts
const {unenrollWithSms} = useMfaEnrollment();

<button
 onClick={() => {
   unenrollWithSms();
 }}
>
Unenroll in SMS MFA
</button>

Example

ts
const {unenrollWithTotp} = useMfaEnrollment();

<button
 onClick={() => {
   unenrollWithTotp();
 }}
>
 Unenroll in TOTP MFA
</button>