-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
57 lines (41 loc) · 1.75 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.14.0/firebase-app.js";
import { getAuth, GoogleAuthProvider, signInWithPopup } from "https://www.gstatic.com/firebasejs/10.14.0/firebase-auth.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/10.14.0/firebase-analytics.js";
const firebaseConfig = {
apiKey: "AIzaSyCKs3hks63jsziwhXjsV__SBUM9mNIXhP8",
authDomain: "flix-got.firebaseapp.com",
projectId: "flix-got",
storageBucket: "flix-got.appspot.com",
messagingSenderId: "930519679112",
appId: "1:930519679112:web:93888fb8165c6b1b529f3d",
measurementId: "G-V8Z4LYG0SH"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
auth.languageCode = 'en'
const provider = new GoogleAuthProvider();
const analytics = getAnalytics(app);
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 = "../logged.html";
}).catch((error) => {
// Handle Errors here.
const errorCode = error.code;
const errorMessage = error.message;
});
})
function updateUserProfile(user) {
const userName = user.displayName;
const userEmail = user.email;
const userProfilePicture = user.photoURL;
document.getElementById("userName").textContent = userName;
document.getElementById("userEmail").textContent = userEmail;
document.getElementById("userProfilePicture").src = userProfilePicture;
}
updateUserProfile()