verifyTwoFactorAuthCode method

Future<User> verifyTwoFactorAuthCode(
  1. String code
)

Implementation

Future<User> verifyTwoFactorAuthCode(String code) async {
  if (_tokens == null) throw const LoginRequiredException();
  if (_isExpired(_tokens!.token)) {
    await _clearAuth();
    throw const TokenExpiredException();
  }
  if (!_isPendingTwoFactorAuth()) {
    throw const AlreadyAuthenticatedException();
  }

  dynamic json = await _post(_config.getAuthUrl('/verify-2fa'), {
    'code': code,
  }, useAuthBodyTransport: true);
  await _setTokens(_tokensFrom(json, 'The two factor response'));
  _pendingLinkToken = null;
  return getUser(forceRefresh: true);
}