fix(auth): wipe account-bound data on logout (closes #18) #30
No reviewers
Labels
No labels
auth
bug
composer
correctness
database
durability
enhancement
feeds
interactions
notifications
performance
reliability
safety
security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starsetbyte/peregrine!30
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/logout-clears-account-data"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Logout cleared auth tokens (and, since a prior fix, the OAuth store) but left all account-bound caches in place. A second account signing in on the same device saw the first account's timeline, custom feeds, drafts, and notifications (issue #18).
Fix
New
AccountDataCleaner, called fromAuthRepository.logout(), wipes every account-bound store:clearAllTables): posts, feed cursors, drafts, notificationsComposerRepository.deleteAllDraftImages) — these are files keyed by draft id, not Room rowsFeedPreferencesRepository.clearLocalData) — including the in-memorycachedRawPreferences/cachedSavedItemssnapshot, since the repo is a@Singletonthat survives logoutSearchRepository.clearLocalData)App-level settings (theme, dynamic color, OAuth-migration dismissal) live in
SettingsRepositoryand are intentionally preserved — they belong to the device, not the account. The wipe is local-only, so it runs whether or not the serverdeleteSessionsucceeds.Tests
AccountDataCleanerTest— verifies all four stores are wipedLocalDataClearTest— bothclearLocalDatamethods remove their keys and leavetheme_modeintactAuthRepositoryTest— logout invokes the cleanerFakePreferencesDataStoreinto a shared test helperFull unit suite green except the pre-existing, unrelated
NotificationsRepositoryTestfailure (fixed separately in PR #29).Known follow-ups (out of scope)
TokenAuthenticator's forced logout callsSessionManager.clearSession()directly and does not route throughlogout(), so an expired session followed by a different account login isn't covered yet. Best addressed together with per-DID scoping (clear-on-account-change at the login boundary), which also cleanly covers the OAuth login path (it bypasses AuthRepository via OAuthLoginViewModel).🤖 Generated with Claude Code
https://claude.ai/code/session_0151pbAku7AeA9fgzWKVQLPE