setUpTotp method

  1. @override
Future<TotpSetupDetails> setUpTotp({
  1. TotpSetupOptions? options,
})
inherited

Initiates setup of a time-based one-time passcode (TOTP) MFA method for the current user.

NOTE: Your backend must be set up with TOTP MFA enabled prior to calling this method.

The TotpSetupDetails returned contains a TotpSetupDetails.getSetupUri method for retrieving the setup URI. This can be used to build a QR code or a button which opens the user's installed authenticator app. After setup is complete on the user's end, call verifyTotpSetup with a one-time code to complete registration.

Implementation

@override
Future<TotpSetupDetails> setUpTotp({TotpSetupOptions? options}) async {
  final machine = _stateMachine.getOrCreate(TotpSetupStateMachine.type);
  final state = await machine
      .dispatchAndComplete<TotpSetupRequiresVerification>(
        const TotpSetupEvent.initiate(),
      );
  return state.result;
}