forked from ankit071105/Ticket-Booking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
firebase.js
45 lines (38 loc) · 1.31 KB
/
firebase.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
const firebaseConfig = {
apiKey: "AIzaSyDMIOxJSByLu96mGV6kAhwMVVVo7sebBdM",
authDomain: "ticket-booking-4e35f.firebaseapp.com",
projectId: "ticket-booking-4e35f",
storageBucket: "ticket-booking-4e35f.appspot.com",
messagingSenderId: "735303265369",
appId: "1:735303265369:web:07e050aae870d80987d548",
measurementId: "G-VNMJ68NQTD"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
// Initialize Firebase Auth
const auth = firebase.auth();
// Google Authentication function
function signInWithGoogle() {
var provider = new firebase.auth.GoogleAuthProvider();
auth
.signInWithPopup(provider)
.then((result) => {
const user = result.user;
console.log("User signed in:", user);
// Redirect to dashboard or any page after successful login
window.location.href = "../../index.html";
})
.catch((error) => {
console.log("Error during sign-in:", error);
});
}
document.getElementById('googleSignup').addEventListener('click', function(e) {
// TODO: Handle Google Sign-In logic here
e.preventDefault();
signInWithGoogle();
});
document.getElementById('googleSignin').addEventListener('click', function(e) {
// TODO: Handle Google Sign-In logic here
e.preventDefault();
signInWithGoogle(); // Use the same function as in register.html
});