audio streaming app plyr.fm
38
fork

Configure Feed

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

fix: invalidate layout data after token exchange (#508)

after exchanging the OAuth token for a session cookie, the root
layout's load function still has stale data (isAuthenticated: false)
from before the cookie was set.

this caused navigation to /library immediately after login to redirect
to / because the layout data said the user wasn't authenticated.

the fix: call invalidateAll() after successful token exchange so
SvelteKit reruns all load functions with the new session cookie.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

authored by zzstoatzz.io

Claude and committed by
GitHub
e1cba451 b4bc517f

+10 -2
+3 -1
frontend/src/routes/portal/+page.svelte
··· 1 1 <script lang="ts"> 2 2 import { onMount } from 'svelte'; 3 - import { replaceState } from '$app/navigation'; 3 + import { invalidateAll, replaceState } from '$app/navigation'; 4 4 import Header from '$lib/components/Header.svelte'; 5 5 import HandleSearch from '$lib/components/HandleSearch.svelte'; 6 6 import AlbumSelect from '$lib/components/AlbumSelect.svelte'; ··· 77 77 }); 78 78 79 79 if (exchangeResponse.ok) { 80 + // invalidate all load functions so they rerun with the new session cookie 81 + await invalidateAll(); 80 82 await auth.initialize(); 81 83 await preferences.fetch(); 82 84 }
+3 -1
frontend/src/routes/profile/setup/+page.svelte
··· 2 2 <script lang="ts"> 3 3 import { APP_NAME } from '$lib/branding'; 4 4 import { onMount } from 'svelte'; 5 - import { replaceState } from '$app/navigation'; 5 + import { invalidateAll, replaceState } from '$app/navigation'; 6 6 import { API_URL } from '$lib/config'; 7 7 import { auth } from '$lib/auth.svelte'; 8 8 ··· 32 32 }); 33 33 34 34 if (exchangeResponse.ok) { 35 + // invalidate all load functions so they rerun with the new session cookie 36 + await invalidateAll(); 35 37 await auth.initialize(); 36 38 } 37 39 } catch (_e) {
+4
frontend/src/routes/settings/+page.svelte
··· 1 1 <script lang="ts"> 2 2 import { onMount } from 'svelte'; 3 + import { invalidateAll } from '$app/navigation'; 3 4 import Header from '$lib/components/Header.svelte'; 4 5 import WaveLoading from '$lib/components/WaveLoading.svelte'; 5 6 import type { TokenInfo } from '$lib/types'; ··· 65 66 66 67 if (exchangeResponse.ok) { 67 68 const data = await exchangeResponse.json(); 69 + 70 + // invalidate all load functions so they rerun with the new session cookie 71 + await invalidateAll(); 68 72 69 73 if (isDevToken) { 70 74 developerToken = data.session_id;