Manage MFA
The manageMFA method opens the account dashboard where users can manage their multi-factor
authentication (MFA) factors.
It accepts an optional LoginParams parameter and returns true when the flow completes.
The SDK reuses the auth connection from the user's current session.
- If you use a default sign-in provider, call
manageMFA()without arguments. - If you use a custom auth connection that needs extra sign-in options (for example, Auth0), pass a
LoginParamsobject with the sameextraLoginOptionsyou used to sign in.
warning
The user must have MFA enabled. Otherwise, manageMFA throws Web3AuthError.mfaNotEnabled.
Users who signed in with an idToken (single-factor authentication) can't manage MFA, and the
method throws Web3AuthError.enabledMfaNotAllowed.
Usage
- Default Auth Connection
- Custom Auth Connection
do {
let response = try await web3Auth.manageMFA()
if response {
// Handle success
} else {
// Something went wrong
}
} catch {
// Handle error
}
let loginParams = LoginParams(
authConnection: .CUSTOM,
extraLoginOptions: ExtraLoginOptions(
domain: "https://username.us.auth0.com", // Domain of your Auth0 app
userIdField: "sub"
)
)
do {
let response = try await web3Auth.manageMFA(loginParams)
if response {
// Handle success
} else {
// Something went wrong
}
} catch {
// Handle error
}