Full document, spreadsheet, slideshow, and diagram tooling
0
fork

Configure Feed

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

fix: mobile OAuth callback not dismissing sign-in screen (#15)

scott 688cf5cd 0b58e7e2

+16 -1
+16 -1
src/lib/auth.ts
··· 61 61 }; 62 62 } 63 63 64 + export function isOAuthCallback(): boolean { 65 + const params = new URLSearchParams(window.location.search); 66 + return params.has('code') && params.has('state'); 67 + } 68 + 64 69 export async function initAuth(): Promise<AtmosSession | null> { 70 + const wasCallback = isOAuthCallback(); 71 + 65 72 try { 66 73 const client = await getClient(); 67 74 const result = await client.init(); ··· 69 76 if (result?.session) { 70 77 _session = await buildSession(result.session); 71 78 window.dispatchEvent(new CustomEvent(SESSION_EVENT, { detail: _session })); 79 + if (wasCallback) { 80 + history.replaceState(null, '', window.location.pathname); 81 + } 72 82 return _session; 73 83 } 74 84 } catch (err) { 75 85 console.error('Auth init failed:', err); 76 86 } 77 87 88 + if (wasCallback) { 89 + console.warn('OAuth callback detected but session restoration failed — clearing URL params'); 90 + history.replaceState(null, '', window.location.pathname); 91 + } 92 + 78 93 return null; 79 94 } 80 95 ··· 82 97 const client = await getClient(); 83 98 try { 84 99 const url = await client.authorize(handle); 85 - window.open(url as unknown as string, '_self'); 100 + window.location.href = url.toString(); 86 101 } catch (err) { 87 102 const message = err instanceof Error ? err.message : 'Authorization failed'; 88 103 throw new Error(`Sign-in failed for @${handle}: ${message}`);