consumePendingImmediatePrompt method

Future<Ntut8021xImmediatePromptData?> consumePendingImmediatePrompt()

Implementation

Future<Ntut8021xImmediatePromptData?> consumePendingImmediatePrompt() async {
  if (!await _isWifiEnabled()) return null;
  if ((await _provisioner.getCapabilities())
          .isSuggestionPermissionDisallowed &&
      (await _stateStore.read()).pendingCompatPromptReason ==
          Ntut8021xStoredPendingPromptReason.suggestionFallbackRequired) {
    await _stateStore.clearPendingCompatPrompt();
    return null;
  }
  final storedReason = await _stateStore.consumePendingCompatPrompt();
  final reason = _pendingPromptReasonFromStored(storedReason);
  if (reason == null) return null;

  final credentials = await _authRepository.getStoredCredentials();
  if (credentials == null) return null;
  if (!await _isWifiEnabled()) return null;

  return Ntut8021xImmediatePromptData(
    reason: reason,
    identity: credentials.username,
    password: credentials.password,
  );
}