Hunde-Cache leeren bei Logout/401 — kein Durchschimmern auf neuen User

Bug: ActiveDogStore cached dogs + activeDogId (UserDefaults). Beim
Login mit einem neuen Account waren die Hunde des vorigen Users
weiter zu sehen, weil HeimView nur loadDogs() ruft wenn dogs.isEmpty.

Fix:
- ActiveDogStore hat jetzt reset() (dogs=[], activeDogId=0,
  UserDefaults gelöscht).
- ActiveDogStore hört auf .userDidLogout und auf .apiUnauthorized,
  beides löst reset() aus.
- AuthSession.logout() postet jetzt .userDidLogout.
- Nach Login holt HeimView's .task automatisch die neuen Hunde
  (dogs.isEmpty → loadDogs).
This commit is contained in:
rene 2026-05-30 18:25:23 +02:00
parent 89d1d47ca4
commit 546386dcbd
2 changed files with 33 additions and 0 deletions

View file

@ -55,6 +55,8 @@ final class AuthSession {
userName = nil
isPremium = false
profile = nil
// Andere Stores benachrichtigen, damit sie ihren User-Cache leeren.
NotificationCenter.default.post(name: .userDidLogout, object: nil)
}
/// Fetches the full user profile from /api/auth/me. Called after login and