verifySoftwareToken method

Future<bool> verifySoftwareToken({
  1. required String totpCode,
  2. String? friendlyDeviceName,
})

This is used to verify a TOTP MFA

Implementation

Future<bool> verifySoftwareToken({
  required String totpCode,
  String? friendlyDeviceName,
}) async {
  if (_signInUserSession != null && _signInUserSession!.isValid()) {
    final data = await client!.request('VerifySoftwareToken', {
      'AccessToken': _signInUserSession!.getAccessToken().getJwtToken(),
      'UserCode': totpCode,
      'FriendlyDeviceName': friendlyDeviceName ?? 'My TOTP device',
    });

    return data['Status'] == 'SUCCESS';
  } else if (_session != null) {
    final data = await client!.request('VerifySoftwareToken', {
      'Session': _session,
      'UserCode': totpCode,
      'FriendlyDeviceName': friendlyDeviceName ?? 'My TOTP device',
    });

    return data['Status'] == 'SUCCESS';
  }

  throw Exception("User is not authenticated");
}