enableTwoFactor method

Future<EnableTwoFactorResponse> enableTwoFactor({
  1. required String password,
  2. String? issuer,
})

Enable two factor This will generate a TOTP URI and backup codes. Once the user verifies the TOTP URI, the two factor authentication will be enabled.

password The password of the user issuer Custom issuer for the TOTP URI

Implementation

Future<EnableTwoFactorResponse> enableTwoFactor({required String password, String? issuer}) async {
  try {
    final response = await dio.post(
      "/two-factor/enable",
      data: {"password": password, "issuer": issuer},
      options: await super.getOptions(),
    );
    return EnableTwoFactorResponse.fromJson(response.data);
  } catch (e) {
    final message = getErrorMessage(e);
    if (message == null) rethrow;
    throw message;
  }
}