audio streaming app plyr.fm
38
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: refresh auth state after account switch/login (#887)

AuthManager.initialize() guards with an `initialized` flag, so after the
layout's onMount sets it, exchange-token flows silently no-op — leaving
stale user data. Add refresh() that resets the flag before re-fetching,
and use it in all 4 exchange-token call sites.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

authored by

nate nowack
Claude Opus 4.6
and committed by
GitHub
51b09978 4bc83742

+9 -4
+5
frontend/src/lib/auth.svelte.ts
··· 71 71 this.initialized = false; 72 72 } 73 73 74 + async refresh(): Promise<void> { 75 + this.initialized = false; 76 + await this.initialize(); 77 + } 78 + 74 79 async logout(): Promise<void> { 75 80 try { 76 81 await fetch(`${API_URL}/auth/logout`, {
+1 -1
frontend/src/routes/library/+page.svelte
··· 41 41 if (exchangeResponse.ok) { 42 42 // invalidate all load functions so they rerun with the new session cookie 43 43 await invalidateAll(); 44 - await auth.initialize(); 44 + await auth.refresh(); 45 45 await preferences.fetch(); 46 46 } 47 47 } catch (_e) {
+1 -1
frontend/src/routes/portal/+page.svelte
··· 122 122 if (exchangeResponse.ok) { 123 123 // invalidate all load functions so they rerun with the new session cookie 124 124 await invalidateAll(); 125 - await auth.initialize(); 125 + await auth.refresh(); 126 126 await preferences.fetch(); 127 127 } 128 128 } catch (_e) {
+1 -1
frontend/src/routes/profile/setup/+page.svelte
··· 33 33 if (exchangeResponse.ok) { 34 34 // invalidate all load functions so they rerun with the new session cookie 35 35 await invalidateAll(); 36 - await auth.initialize(); 36 + await auth.refresh(); 37 37 } 38 38 } catch (_e) { 39 39 console.error('failed to exchange token:', _e);
+1 -1
frontend/src/routes/settings/+page.svelte
··· 79 79 showTokenOverlay = true; // show full-page overlay immediately 80 80 } else if (isScopeUpgrade) { 81 81 // reload auth state with new session 82 - await auth.initialize(); 82 + await auth.refresh(); 83 83 await preferences.fetch(); 84 84 toast.success('teal.fm scrobbling connected!'); 85 85 }