verify method

Future<AuthyoResult> verify()

Implementation

Future<AuthyoResult> verify() async {
  errorMessage = null;
  infoMessage = null;
  if (otp.trim().isEmpty) {
    errorMessage = 'Please enter the OTP';
    notifyListeners();
    return AuthyoResult.failure(BadRequestError(errorMessage!));
  }
  _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) {
    errorMessage = res.error!.message;
  } else {
    _timer?.cancel();
    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;
}