Skip to main content

Security

Enable MFA and delete a user account.

note

userInstanceESPRMUser from User sign in.

What This Module Does ?

Configures multi-factor authentication (MFA) and runs the account deletion flow (request + confirm with verification code).

Use MFA when your deployment requires an extra sign-in factor. Use account deletion for in-app “delete my account” compliance flows.

Expected outcome: MFA enabled or disabled on the user; account removed after confirmed deletion.

Common Workflows

Configure MFA

await userInstance.configureMFA(true);
await userInstance.configureMFA(false);

Delete account (two steps)

await userInstance.requestAccountDeletion();
await userInstance.confirmAccountDeletion(verificationCode);

Error Handling

try {
await userInstance.confirmAccountDeletion(verificationCode);
} catch (error) {
console.error("Account deletion failed:", error);
}

After successful deletion, clear local tokens and return to login.

Best Practices

  1. Confirm deletion in UI before calling requestAccountDeletion
  2. Sign out and clear tokens after confirmAccountDeletion
  3. Explain MFA impact before enabling—login flow may change

On this page