verifyTOTP method

  1. @override
Future<void> verifyTOTP(
  1. String code
)
override

Verifies the TOTP setup by validating a code generated by the token generator app with the current setup

Implementation

@override
Future<void> verifyTOTP(
  String code,
) async {
  try {
    await _amplifyAuth.verifyTotpSetup(code);
    _logger.fine(
      'Successfully confirmed TOTP code',
    );
  } on aws_cognito.CodeMismatchException catch (e) {
    throw InvalidCodeException(
      message: e.message,
      innerException: e,
      innerStackTrace: StackTrace.current,
    );
  } on aws_cognito.ExpiredCodeException catch (e) {
    throw ExpiredCodeException(
      message: e.message,
      innerException: e,
      innerStackTrace: StackTrace.current,
    );
  } on aws_cognito.AuthException catch (e) {
    throw TOTPVerifyException(
      message: 'Failed to verify TOTP for user',
      innerException: e,
      innerStackTrace: StackTrace.current,
    );
  }
}