-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
34 lines (29 loc) · 1.24 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.13.2/firebase-app.js";
import { getAuth, GoogleAuthProvider, signInWithPopup } from "https://www.gstatic.com/firebasejs/10.13.2/firebase-auth.js";
const firebaseConfig = {
apiKey: "AIzaSyCmbzHk_9FLW99YV56Q6IC4Izs7bbe56C8",
authDomain: "login-8149c.firebaseapp.com",
projectId: "login-8149c",
storageBucket: "login-8149c.appspot.com",
messagingSenderId: "305938977946",
appId: "1:305938977946:web:7f321b05704c6d498abb23",
measurementId: "G-QW1KFFPPLF"
};
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
auth.languageCode = 'en';
const provider = new GoogleAuthProvider();
const googleLogin = document.getElementById("google-login-btn");
googleLogin.addEventListener("click", function () {
signInWithPopup(auth, provider)
.then((result) => {
const credential = GoogleAuthProvider.credentialFromResult(result);
const user = result.user;
console.log(user);
window.location.href = "../index.html"; // Redirect after successful login
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
});
});