verify method
Implementation
Future<AuthyoResult> verify() async {
errorMessage = null;
infoMessage = null;
otpError = null;
if (otp.trim().isEmpty) {
otpError = 'Please enter the OTP';
notifyListeners();
return AuthyoResult.failure(BadRequestError(otpError!));
}
_setLoading(true);
final remember = rememberMeEnabled && rememberMe;
final res = await _service.verifyOtp(
maskId: maskId ?? '',
otp: otp.trim(),
rememberMe: remember,
);
if (_disposed) return res;
if (res.error != null) {
// Same copy as the web widget's inline error; the pill takes the
// updated count from the reply.
otpError = 'Invalid OTP. Please try again.';
if (res.attempts != null) attempts = res.attempts;
if (attempts?.lockedOut ?? false) {
// Nothing left to do on this screen: the session is dead until the
// server's lockout window passes. Stop the countdowns so the screen
// never shows "expires in 8:44" next to "no attempts remaining".
stopTimers();
lockedOut = true;
otpError = null;
}
} else {
stopTimers();
verified = true;
completed = res;
// Like the web widget: remember the identity only when the option is
// on and the box is ticked; otherwise make sure nothing is kept.
if (remember) {
unawaited(_service.rememberIdentity(to));
} else {
unawaited(_service.forgetIdentity());
}
}
_setLoading(false);
return res;
}