Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions firebase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/ Import the necessary Firebase modules
import firebase from 'firebase/app';
import 'firebase/auth';

// Initialize Firebase (Make sure you have already set up your Firebase project)
const firebaseConfig = {
// Your Firebase config object goes here
};
firebase.initializeApp(firebaseConfig);

// Get the Firebase auth instance
const auth = firebase.auth();

// Create a Google authentication provider
const provider = new firebase.auth.GoogleAuthProvider();

// Function to handle Google sign-in
function signInWithGoogle() {
auth.signInWithPopup(provider)
.then((result) => {
// Successful authentication
const user = result.user;
console.log('Authenticated user:', user);
})
.catch((error) => {
// Failed authentication
console.log('Authentication failed:', error.message);
});
}

// Call the signInWithGoogle function when the login button is clicked
const loginButton = document.getElementById('login-button');
loginButton.addEventListener('click', signInWithGoogle);