verifyTOTP method
Future<VerifyTOTP200Response?>
verifyTOTP(
- String userId, {
- VerifyTOTPRequest? verifyTOTPRequest,
Verify a TOTP or backup code for a user
Verify that the provided TOTP or backup code is valid for the user. Verifying a backup code will result it in being consumed (i.e. it will become invalid). Useful for custom auth flows and re-verification.
Parameters:
-
String userId (required): The ID of the user for whom to verify the TOTP
-
VerifyTOTPRequest verifyTOTPRequest:
Implementation
Future<VerifyTOTP200Response?> verifyTOTP(
String userId, {
VerifyTOTPRequest? verifyTOTPRequest,
}) async {
final response = await verifyTOTPWithHttpInfo(
userId,
verifyTOTPRequest: verifyTOTPRequest,
);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty &&
response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(
await _decodeBodyBytes(response),
'VerifyTOTP200Response',
) as VerifyTOTP200Response;
}
return null;
}