> For the complete documentation index, see [llms.txt](/llms.txt).

# Enable MFA

The `enableMFA` method triggers multi-factor authentication (MFA) setup for a signed-in user, adding an additional recovery factor to protect wallet access. It accepts an optional `LoginParams` parameter and returns `true` when the setup flow completes.

The SDK reuses the auth connection from the user's current session.

- If you use a default sign-in provider, call `enableMFA()` without arguments.
- If you use a custom auth connection that needs extra sign-in options (for example, Auth0), pass a `LoginParams` object with the same `extraLoginOptions` you used to sign in.

warning

Users who signed in with an `idToken` (single-factor authentication) can't enable MFA. `enableMFA` throws `Web3AuthError.enabledMfaNotAllowed` for these users. It throws `Web3AuthError.mfaAlreadyEnabled` if the user already has MFA enabled, and `Web3AuthError.noUserFound` if no user is signed in.

## Usage

**Default Auth Connection**

```swift
do {
  let isMFAEnabled = try await web3Auth.enableMFA()
} catch {
  print(error.localizedDescription)
  // Handle Error
}

```

**Custom Auth Connection**

```swift
do {
    let loginParams = LoginParams(
        authConnection: .CUSTOM,
        extraLoginOptions: ExtraLoginOptions(
            domain: "https://username.us.auth0.com", // Domain of your Auth0 app
            userIdField: "sub"
        )
    )

    let isMFAEnabled = try await web3Auth.enableMFA(loginParams)
} catch {
    print(error.localizedDescription)
    // Handle Error
}

```
