Security
Enable MFA and delete a user account.
备注
userInstance — ESPRMUser 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
- Confirm deletion in UI before calling
requestAccountDeletion - Sign out and clear tokens after
confirmAccountDeletion - Explain MFA impact before enabling—login flow may change
Related Resource
- API Reference: