fix(auth): ATTEMPTED fix for google oauth (lowk havent tested this)

This commit is contained in:
Samidy 2026-03-07 02:42:30 +03:00 committed by GitHub
parent 135caf101f
commit e15ca352a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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');