screen-locker/stronglift_replacement/workout_app/lib/services
Krzysztof kuhy Rudnicki b026dfd074 Recover the sync token from backup when the stored one is rejected
SyncSettings.load() prefers the keystore and only consults the external
backup when the keystore is EMPTY. So a stale keystore entry — one left by
an earlier authorization — shadows a perfectly good backup indefinitely:
every sync 401s and the user is told to re-authorize for nothing. This is
not hypothetical; it is the most likely explanation for the phone's 401,
whose token turned out to be healthy (GET /user 200, scope repo) once read
from the backup.

- SyncSettings.recoverFromBackup(rejectedToken) re-seeds the keystore from
  the backup and returns the recovered token, or null when there is nothing
  to recover (no backup, empty, or the same token that was just rejected).
- settings_screen retries verification once via the backup before demanding
  re-auth, and says so ("recovered the saved token from backup") instead of
  nagging.
- workout_sync_service retries the read once from the backup, so history
  self-heals without the user having to visit Settings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fv8ULVt3Q67GwCFbM7doHB
2026-07-17 09:45:12 +02:00
..
backup_service.dart Cover services + app bootstrap toward 100% flutter coverage 2026-07-13 13:27:18 +02:00
github_device_auth.dart Add phone-workout GitHub sync via shared crdt_sync (Workstream C) 2026-07-11 00:06:59 +02:00
http_server_service.dart Cover services + app bootstrap toward 100% flutter coverage 2026-07-13 13:27:18 +02:00
storage_service.dart Fix flutter analyze infos for the push gate 2026-07-13 14:28:45 +02:00
sync_service.dart Fix flutter analyze infos for the push gate 2026-07-13 14:28:45 +02:00
sync_settings.dart Recover the sync token from backup when the stored one is rejected 2026-07-17 09:45:12 +02:00
workout_sync_service.dart Recover the sync token from backup when the stored one is rejected 2026-07-17 09:45:12 +02:00