Fix CM1000 multi-login recovery: release the old session, then log in again - #6
Merged
Merged
Conversation
The "you are currently logged in from another device" interstitial is not a
one-click takeover. Clicking "Yes" (POST /goform/MultiLogin) only RELEASES
the existing admin session and bounces back to the login page -- the modem
then admits the NEXT login. The previous fix did the "Yes" POST and treated
the resulting login page as failure, so recovery never completed (observed
in syslog: "taking it over" immediately followed by "received the login form
again", looping every interval).
Rework login() to mirror the browser flow on a single shared Session (so
cookies persist/update automatically):
1. _attempt_login(): GET login page for a fresh webToken, POST credentials
2. if the interstitial comes back, _confirm_multi_login() POSTs "Yes" to
release the old session
3. _attempt_login() again on the same Session to actually get in
Also build the "Yes" payload from the interstitial's real hidden inputs via
_hidden_form_fields() (Act / RetailSessionId / webToken as served) instead of
guessed empty strings, so the modem sees its own session identifiers.
Tests: add _hidden_form_fields coverage for the interstitial HTML.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018bKShZ5y7RFZzqfbkn6WZq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the CM1000 failing to recover when the modem is already holding an admin session (the "you are currently logged in from another device" interstitial). The prior handling detected the interstitial but never completed login, so the scraper looped on it every interval and never got in.
Root cause
Clicking "Yes" on that interstitial is not a one-click takeover.
POST /goform/MultiLoginonly releases the existing admin session and bounces back to the login page — the modem then admits the next login. The previous code did the "Yes" POST and treated the resulting login page as a failure, so recovery never completed. In syslog this showed up as:…repeating every interval.
Fix
login()now mirrors what a browser does, on a single sharedrequests.Sessionso cookies persist and update automatically:_attempt_login()— GET the login page for a freshwebToken, POST credentials._confirm_multi_login()POSTs "Yes" to release the existing session._attempt_login()again on the same session to actually get in.Additional robustness: the "Yes" payload is now built from the interstitial's real hidden inputs via
_hidden_form_fields()(Act/RetailSessionId/webTokenexactly as served), instead of the guessed empty strings the first version sent — so the modem sees its own session identifiers.The false-positive guard remains:
login()only returns a session once the response is confirmed to be neither the login form nor the interstitial, so a failed recovery can never hand back a dead session (which is what caused the original multi-hour stall after an outage).Test plan
bash tests/run_tests.sh— all 11 tests passtest_hidden_form_fields_multi_logincovering theAct/RetailSessionId/ unquoted-webTokenextraction from the interstitial HTMLreleasing it ("Yes") and re-logging in, a secondObtaining login session…, thenRetreiving stats…with no "received the login form again"🤖 Generated with Claude Code
Generated by Claude Code