diff --git a/src/lib/atproto/auth.svelte.ts b/src/lib/atproto/auth.svelte.ts index b9dd5e2..1715862 100644 --- a/src/lib/atproto/auth.svelte.ts +++ b/src/lib/atproto/auth.svelte.ts @@ -126,6 +126,8 @@ async function startAuthorization(identity?: ActorIdentifier) { scope: metadata.scope }); + localStorage.setItem('login-redirect', location.pathname + location.search); + // let browser persist local storage await new Promise((resolve) => setTimeout(resolve, 200)); diff --git a/src/routes/(auth)/oauth/callback/+page.svelte b/src/routes/(auth)/oauth/callback/+page.svelte index 13ef050..00aba26 100644 --- a/src/routes/(auth)/oauth/callback/+page.svelte +++ b/src/routes/(auth)/oauth/callback/+page.svelte @@ -7,9 +7,18 @@ let startedErrorTimer = $state(); + let hasRedirected = $state(false); + $effect(() => { if (user.profile) { - goto('/' + getHandleOrDid(user.profile) + '/edit', {}); + if(hasRedirected) return; + + const redirect = localStorage.getItem('login-redirect'); + localStorage.removeItem('login-redirect'); + console.log('redirect', redirect) + goto(redirect || '/' + getHandleOrDid(user.profile) + '/edit', {}); + + hasRedirected = true; } if (!user.isInitializing && !startedErrorTimer) {