Spaces:
Running
Running
Delete scripts/scriptsfirebase.js
Browse files- scripts/scriptsfirebase.js +0 -58
scripts/scriptsfirebase.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
| 1 |
-
import {
|
| 2 |
-
initializeApp
|
| 3 |
-
} from "https://www.gstatic.com/firebasejs/11.6.1/firebase-app.js";
|
| 4 |
-
import {
|
| 5 |
-
getAuth,
|
| 6 |
-
onAuthStateChanged,
|
| 7 |
-
signOut,
|
| 8 |
-
signInAnonymously,
|
| 9 |
-
GoogleAuthProvider,
|
| 10 |
-
signInWithPopup
|
| 11 |
-
} from "https://www.gstatic.com/firebasejs/11.6.1/firebase-auth.js";
|
| 12 |
-
|
| 13 |
-
const firebaseConfig = {
|
| 14 |
-
apiKey: import.meta.env.FIREBASE_API_KEY,
|
| 15 |
-
authDomain: import.meta.env.FIREBASE_AUTH_DOMAIN,
|
| 16 |
-
projectId: import.meta.env.FIREBASE_PROJECT_ID,
|
| 17 |
-
storageBucket: import.meta.env.FIREBASE_STORAGE_BUCKET,
|
| 18 |
-
messagingSenderId: import.meta.env.FIREBASE_MESSAGING_SENDER_ID,
|
| 19 |
-
appId: import.meta.env.FIREBASE_APP_ID,
|
| 20 |
-
measurementId: import.meta.env.FIREBASE_MEASUREMENT_ID
|
| 21 |
-
};
|
| 22 |
-
|
| 23 |
-
const app = initializeApp(firebaseConfig);
|
| 24 |
-
const auth = getAuth(app);
|
| 25 |
-
|
| 26 |
-
const loginBtn = document.getElementById("loginAnonButton");
|
| 27 |
-
const logoutBtn = document.getElementById("logoutButton");
|
| 28 |
-
|
| 29 |
-
loginBtn.addEventListener("click", async () => {
|
| 30 |
-
try {
|
| 31 |
-
const provider = new GoogleAuthProvider();
|
| 32 |
-
await signInWithPopup(auth, provider);
|
| 33 |
-
} catch (err) {
|
| 34 |
-
console.error("Error al iniciar sesión:", err);
|
| 35 |
-
}
|
| 36 |
-
});
|
| 37 |
-
|
| 38 |
-
document.getElementById("anonymousLoginButton").addEventListener("click", async () => {
|
| 39 |
-
try {
|
| 40 |
-
await signInAnonymously(auth);
|
| 41 |
-
} catch (error) {
|
| 42 |
-
console.error(error);
|
| 43 |
-
}
|
| 44 |
-
});
|
| 45 |
-
|
| 46 |
-
logoutBtn.addEventListener("click", async () => {
|
| 47 |
-
await signOut(auth);
|
| 48 |
-
});
|
| 49 |
-
|
| 50 |
-
onAuthStateChanged(auth, (user) => {
|
| 51 |
-
if (user) {
|
| 52 |
-
document.getElementById("loginAnonButton").style.display = "none";
|
| 53 |
-
document.getElementById("logoutButton").style.display = "block";
|
| 54 |
-
} else {
|
| 55 |
-
document.getElementById("loginAnonButton").style.display = "block";
|
| 56 |
-
document.getElementById("logoutButton").style.display = "none";
|
| 57 |
-
}
|
| 58 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|