Files
ax3Client/src/firebase.js
Kenneth Jannette 4c1fb67383 first commit
2024-01-11 18:24:41 -06:00

47 lines
1005 B
JavaScript

import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
import {
getAuth,
onAuthStateChanged,
signOut,
signInWithEmailAndPassword,
} from "firebase/auth";
import {
apiKey,
authDomain,
projectId,
storageBucket,
messagingSenderId,
appId,
measurementId,
} from "./secrets";
const firebaseConfig = {
apiKey: apiKey,
authDomain: authDomain,
projectId: projectId,
storageBucket: storageBucket,
messagingSenderId: messagingSenderId,
appId: appId,
measurementId: measurementId,
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
const auth = getAuth(app);
export const signInUser = async (email, password) => {
if (!email && !password) return;
return await signInWithEmailAndPassword(auth, email, password);
};
export const userStateListener = (callback) => {
return onAuthStateChanged(auth, callback);
};
export const SignOutUser = async () => await signOut(auth);
export { auth };
export { db };