From e15ca352a0e834bdb053e948242c986f82c88f02 Mon Sep 17 00:00:00 2001 From: Samidy Date: Sat, 7 Mar 2026 02:42:30 +0300 Subject: [PATCH] fix(auth): ATTEMPTED fix for google oauth (lowk havent tested this) --- js/accounts/auth.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/js/accounts/auth.js b/js/accounts/auth.js index 6d522a9..b6b65d9 100644 --- a/js/accounts/auth.js +++ b/js/accounts/auth.js @@ -12,14 +12,19 @@ export class AuthManager { const params = new URLSearchParams(window.location.search); const userId = params.get('userId'); const secret = params.get('secret'); + const isOAuthRedirect = params.get('oauth') === '1'; - if (userId && secret) { + if (userId && secret && userId !== 'null' && secret !== 'null') { try { await auth.createSession(userId, secret); window.history.replaceState({}, '', window.location.pathname); } catch (error) { - console.error('OAuth session creation failed:', error); + console.warn('OAuth session handoff failed:', error.message); + window.history.replaceState({}, '', window.location.pathname); } + } else if (isOAuthRedirect) { + await new Promise(resolve => setTimeout(resolve, 500)); + window.history.replaceState({}, '', window.location.pathname); } try { @@ -44,7 +49,7 @@ export class AuthManager { try { auth.createOAuth2Session( 'google', - window.location.origin + '/index.html', + window.location.origin + '/index.html?oauth=1', window.location.origin + '/login.html' ); } catch (error) { @@ -118,9 +123,8 @@ export class AuthManager { const emailContainer = document.getElementById('email-auth-container'); const emailToggleBtn = document.getElementById('toggle-email-auth-btn'); - if (!connectBtn) return; // UI might not be rendered yet + if (!connectBtn) return; - // Auth gate active: strip down to status + sign out only if (window.__AUTH_GATE__) { connectBtn.textContent = 'Sign Out'; connectBtn.classList.add('danger');