Skip to content

fix(2fa): request a push notification when re-auth is required - #486

Open
epheterson wants to merge 3 commits into
mandarons:mainfrom
epheterson:fix/2fa-trigger-push
Open

fix(2fa): request a push notification when re-auth is required#486
epheterson wants to merge 3 commits into
mandarons:mainfrom
epheterson:fix/2fa-trigger-push

Conversation

@epheterson

Copy link
Copy Markdown
Contributor

Summary

Split out from #470 per your request — the mechanism-agnostic core bug fix, with the Telegram convenience layer to rebase on top.

The headless sync loop detected "2FA required", notified the user, and retried — but never called trigger_2fa_push_notification, so Apple was never asked to push a code. The user's trusted devices stayed silent and there was nothing to enter. (#471 bumped icloudpy so the trigger works; nothing in icloud-docker actually called it.)

Change

  • _handle_2fa_required now requests the push, best-effort — a failure is logged and never breaks the retry loop.
  • Fired once per re-auth episode, latched on SyncState.two_fa_triggered and reset on the next successful auth, so we don't re-push every retry cycle (default 600s) and trip Apple's rate limits.
  • No new config; behaviour is automatic.

Tests

Full suite green, 100% coverage. Adds direct coverage for: push requested once per episode, not re-requested on subsequent retries within the same episode, and a failing trigger being swallowed without breaking the loop.

The headless sync loop detected "2FA required", notified the user, and
retried -- but never called trigger_2fa_push_notification, so Apple was
never asked to push a code. The user's trusted devices stayed silent and
there was no code to enter.

Wire the trigger into _handle_2fa_required (best-effort; a failure is
logged and never breaks the retry loop). Fire once per re-auth episode,
latched on SyncState.two_fa_triggered and reset on the next successful
auth, so we don't re-push every retry cycle (default 600s) and trip
Apple's rate limits.

No new config; behaviour is automatic. This is the mechanism-agnostic
core fix underneath the Telegram (mandarons#470) and web-UI (mandarons#464) re-auth flows,
split out per maintainer request on mandarons#470.

Co-Authored-By: Claude <noreply@anthropic.com>
@epheterson
epheterson force-pushed the fix/2fa-trigger-push branch from f7c29db to e4dad94 Compare July 21, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants