verifyOtp method
Verify two factor OTP
code The OTP code
trustDevice If true, the device will be trusted for 30 days. It'll be refreshed on every sign in request within this time.
Implementation
Future<UserAndTokenResponse> verifyOtp({required String code, bool trustDevice = false}) async {
try {
final response = await dio.post(
"/two-factor/verify-otp",
data: {"code": code, "trustDevice": trustDevice},
options: await super.getOptions(),
);
final responseData = UserAndTokenResponse.fromJson(response.data);
await super.tokenStore.saveToken(responseData.token);
return responseData;
} catch (e) {
final message = getErrorMessage(e);
if (message == null) rethrow;
throw message;
}
}