-
Notifications
You must be signed in to change notification settings - Fork 0
/
FirebaseConfig.js
44 lines (40 loc) · 1.31 KB
/
FirebaseConfig.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
import { initializeApp } from "firebase/app";
import {
getAuth,
GoogleAuthProvider,
signInWithRedirect,
signOut,
} from "firebase/auth";
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: import.meta.env.VITE_APP_FIREBASE_API_KEY,
authDomain: import.meta.env.VITE_APP_FIREBASE_AUTH_DOMAIN,
projectId: import.meta.env.VITE_APP_FIREBASE_PROJECT_ID,
storageBucket: import.meta.env.VITE_APP_FIREBASE_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_APP_FIREBASE_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_APP_FIREBASE_APP_ID,
measurementId: import.meta.env.VITE_APP_FIREBASE_MEASUREMENT_ID,
};
// Initialize Firebase with only authentication
const app = initializeApp(firebaseConfig, {
/* only Auth */
});
const auth = getAuth(app);
// Function for Google Sign-in with redirect
const signInWithGoogle = () => {
const provider = new GoogleAuthProvider();
signInWithRedirect(auth, provider);
};
// Function for signing out the user
const signOutUser = () => {
signOut(auth)
.then(() => {
// Sign-out successful logic (e.g., redirect to login page)
console.log("User signed out successfully!");
})
.catch((error) => {
// Handle sign-out errors
console.error("Error signing out:", error);
});
};
export { auth, signInWithGoogle, signOutUser };