Skip to content

KOReader Authenticate can skip WiFi connection and fail immediately #404

Description

@bmanturner

Device

X4

Affected Version

v1.4.0 (b7f6708f); the same connection check is also present on the current development branch

EPUB Optimization

No / Not Applicable

Cache State

No / Not Applicable

Describe the Bug

Selecting Authenticate under KOReader Sync can immediately attempt authentication and fail without first connecting to WiFi or opening the WiFi selection/auto-connect flow.

The authentication activity treats WiFi.status() == WL_CONNECTED as sufficient proof of a usable network connection:

// src/activities/settings/KOReaderAuthActivity.cpp
if (WiFi.status() == WL_CONNECTED) {
  onWifiSelectionComplete(true);
  return;
}

onWifiSelectionComplete(true) then immediately calls KOReaderSyncClient::authenticate(). If the ESP32 WiFi stack reports WL_CONNECTED while station mode is inactive, the status is stale, or DHCP has not produced an address, the WiFi selection activity is skipped and authentication runs against an unusable connection.

This check is weaker than equivalent network readiness checks already used elsewhere in CrossInk. For example, OTA and OPDS require both WL_CONNECTED and a non-zero local IP:

WiFi.status() == WL_CONNECTED &&
WiFi.localIP() != IPAddress(0, 0, 0, 0)

KOReaderSyncActivity.cpp has the same status-only check, so manual progress sync may be affected as well.

There is a second UI symptom: after requestUpdate() sets the state to AUTHENTICATING, performAuthentication() runs synchronously. The status screen is therefore not guaranteed to render before an immediate low-memory, client-creation, or transport failure is returned.

Steps to Reproduce

  1. On an X4, configure a KOReader Sync username and password.
  2. Enter Settings > KOReader Sync while WiFi is not visibly connected.
  3. Select Authenticate.
  4. Observe that authentication may begin and fail immediately without showing the WiFi selection or saved-network auto-connect flow.

Expected Behavior

Before authenticating, CrossInk should verify that WiFi is in station mode, reports WL_CONNECTED, and has a non-zero local IP address. If any of those checks fail, it should launch WifiSelectionActivity and authenticate only after that activity reports a successful connection.

The same readiness check should be applied to KOReader progress sync.

Relevant Log Output/Screenshots

Source path on v1.4.0:
KOReaderAuthActivity::onEnter()
  -> WiFi.status() == WL_CONNECTED
  -> onWifiSelectionComplete(true)
  -> performAuthentication()
  -> KOReaderSyncClient::authenticate()

No device serial log was captured. The report is based on the observed X4 behavior and the source-level control flow above.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions