Spaces:
Running
Running
Update index.html
Browse files- index.html +2 -104
index.html
CHANGED
|
@@ -400,7 +400,6 @@
|
|
| 400 |
const saveUsernameButton = document.getElementById('saveUsernameButton');
|
| 401 |
const usernameInput = document.getElementById('usernameInput');
|
| 402 |
const usernameMessage = document.getElementById('usernameMessage');
|
| 403 |
-
const googleLoginButton = document.getElementById('googleLoginButton');
|
| 404 |
const anonymousLoginButton = document.getElementById('anonymousLoginButton');
|
| 405 |
const mainLoginButton = document.getElementById('mainLoginButton');
|
| 406 |
const mainLogoutButton = document.getElementById('mainLogoutButton');
|
|
@@ -448,95 +447,7 @@
|
|
| 448 |
}
|
| 449 |
});
|
| 450 |
|
| 451 |
-
// Google
|
| 452 |
-
googleLoginButton.addEventListener('click', async () => {
|
| 453 |
-
// UI: deshabilitar botón para evitar clics múltiples
|
| 454 |
-
googleLoginButton.disabled = true;
|
| 455 |
-
const originalGoogleText = googleLoginButton.innerText;
|
| 456 |
-
googleLoginButton.innerText = 'Abriendo Google...';
|
| 457 |
-
if (loginMessage) {
|
| 458 |
-
loginMessage.innerText = 'Abriendo ventana de Google...';
|
| 459 |
-
loginMessage.classList.remove('text-red-500');
|
| 460 |
-
}
|
| 461 |
-
try {
|
| 462 |
-
const provider = new GoogleAuthProvider();
|
| 463 |
-
// Sugerir selección de cuenta siempre
|
| 464 |
-
provider.setCustomParameters({ prompt: 'select_account' });
|
| 465 |
-
|
| 466 |
-
// Persistencia según "Recordarme"
|
| 467 |
-
const persistence = rememberMeCheck && rememberMeCheck.checked
|
| 468 |
-
? browserLocalPersistence
|
| 469 |
-
: browserSessionPersistence;
|
| 470 |
-
await setPersistence(auth, persistence);
|
| 471 |
-
const upgradingAnonymous = auth.currentUser && auth.currentUser.isAnonymous;
|
| 472 |
-
// En Hugging Face (Static) forzamos redirect para evitar bloqueos/doble popup
|
| 473 |
-
if (isHFStatic) {
|
| 474 |
-
if (loginMessage) {
|
| 475 |
-
loginMessage.innerText = 'Redirigiendo a Google...';
|
| 476 |
-
}
|
| 477 |
-
if (upgradingAnonymous) {
|
| 478 |
-
// Vincular Google a la sesión anónima existente
|
| 479 |
-
await linkWithRedirect(auth.currentUser, provider);
|
| 480 |
-
} else {
|
| 481 |
-
await signInWithRedirect(auth, provider);
|
| 482 |
-
}
|
| 483 |
-
return;
|
| 484 |
-
}
|
| 485 |
-
|
| 486 |
-
if (upgradingAnonymous) {
|
| 487 |
-
await linkWithPopup(auth.currentUser, provider);
|
| 488 |
-
} else {
|
| 489 |
-
await signInWithPopup(auth, provider);
|
| 490 |
-
}
|
| 491 |
-
} catch (error) {
|
| 492 |
-
console.warn("Google Sign-In con popup falló:", error?.code, error?.message);
|
| 493 |
-
// Solo si el problema es popup bloqueado, hacemos redirect (evita doble popup)
|
| 494 |
-
if (error?.code === 'auth/popup-blocked') {
|
| 495 |
-
try {
|
| 496 |
-
if (loginMessage) {
|
| 497 |
-
loginMessage.innerText = 'Redirigiendo a Google...';
|
| 498 |
-
loginMessage.classList.remove('text-red-500');
|
| 499 |
-
}
|
| 500 |
-
const provider = new GoogleAuthProvider();
|
| 501 |
-
provider.setCustomParameters({ prompt: 'select_account' });
|
| 502 |
-
const upgradingAnonymous = auth.currentUser && auth.currentUser.isAnonymous;
|
| 503 |
-
if (upgradingAnonymous) {
|
| 504 |
-
await linkWithRedirect(auth.currentUser, provider);
|
| 505 |
-
} else {
|
| 506 |
-
await signInWithRedirect(auth, provider);
|
| 507 |
-
}
|
| 508 |
-
return;
|
| 509 |
-
} catch (redirectErr) {
|
| 510 |
-
console.error("Error en signInWithRedirect:", redirectErr);
|
| 511 |
-
}
|
| 512 |
-
} else if (error?.code === 'auth/credential-already-in-use' || error?.code === 'auth/account-exists-with-different-credential') {
|
| 513 |
-
// Si ya existe la cuenta con otras credenciales, intentar un signIn normal por redirect
|
| 514 |
-
try {
|
| 515 |
-
const provider = new GoogleAuthProvider();
|
| 516 |
-
provider.setCustomParameters({ prompt: 'select_account' });
|
| 517 |
-
if (isHFStatic) {
|
| 518 |
-
await signInWithRedirect(auth, provider);
|
| 519 |
-
return;
|
| 520 |
-
} else {
|
| 521 |
-
await signInWithPopup(auth, provider);
|
| 522 |
-
}
|
| 523 |
-
} catch (e2) {
|
| 524 |
-
console.error('Error al recuperar cuenta existente con Google:', e2);
|
| 525 |
-
}
|
| 526 |
-
} else if (error?.code !== 'auth/popup-closed-by-user') {
|
| 527 |
-
// Si el usuario cerró el popup, no mostrar error intrusivo
|
| 528 |
-
console.error("Error con Google Sign-In:", error);
|
| 529 |
-
if (loginMessage) {
|
| 530 |
-
loginMessage.innerText = `Error con Google: ${error.message}`;
|
| 531 |
-
loginMessage.classList.add('text-red-500');
|
| 532 |
-
}
|
| 533 |
-
}
|
| 534 |
-
} finally {
|
| 535 |
-
// Rehabilitar si seguimos en la misma página (si hubo redirect, no se ejecutará esto)
|
| 536 |
-
googleLoginButton.disabled = false;
|
| 537 |
-
googleLoginButton.innerText = originalGoogleText;
|
| 538 |
-
}
|
| 539 |
-
});
|
| 540 |
|
| 541 |
// anonymous login (from modal)
|
| 542 |
anonymousLoginButton.addEventListener('click', async () => {
|
|
@@ -567,20 +478,7 @@
|
|
| 567 |
}
|
| 568 |
});
|
| 569 |
|
| 570 |
-
//
|
| 571 |
-
try {
|
| 572 |
-
const redirectResult = await getRedirectResult(auth);
|
| 573 |
-
if (redirectResult && redirectResult.user) {
|
| 574 |
-
console.log('Redirect completado. Usuario:', redirectResult.user.uid);
|
| 575 |
-
// onAuthStateChanged gestionará el resto (UI, escena, etc.)
|
| 576 |
-
if (loginMessage) {
|
| 577 |
-
loginMessage.innerText = 'Autenticación completada.';
|
| 578 |
-
loginMessage.classList.remove('text-red-500');
|
| 579 |
-
}
|
| 580 |
-
}
|
| 581 |
-
} catch (redirectCheckErr) {
|
| 582 |
-
console.warn('Error al obtener resultado de redirect de Google:', redirectCheckErr);
|
| 583 |
-
}
|
| 584 |
|
| 585 |
// save username for new accounts (modal)
|
| 586 |
saveUsernameButton.addEventListener('click', async () => {
|
|
|
|
| 400 |
const saveUsernameButton = document.getElementById('saveUsernameButton');
|
| 401 |
const usernameInput = document.getElementById('usernameInput');
|
| 402 |
const usernameMessage = document.getElementById('usernameMessage');
|
|
|
|
| 403 |
const anonymousLoginButton = document.getElementById('anonymousLoginButton');
|
| 404 |
const mainLoginButton = document.getElementById('mainLoginButton');
|
| 405 |
const mainLogoutButton = document.getElementById('mainLogoutButton');
|
|
|
|
| 447 |
}
|
| 448 |
});
|
| 449 |
|
| 450 |
+
// (Google eliminado) Solo Email/Password y Anónimo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 451 |
|
| 452 |
// anonymous login (from modal)
|
| 453 |
anonymousLoginButton.addEventListener('click', async () => {
|
|
|
|
| 478 |
}
|
| 479 |
});
|
| 480 |
|
| 481 |
+
// (Google eliminado) No hay procesamiento de redirect
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 482 |
|
| 483 |
// save username for new accounts (modal)
|
| 484 |
saveUsernameButton.addEventListener('click', async () => {
|