55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
import * as firebase from "firebase/app";
|
|
import "firebase/auth";
|
|
|
|
//const config = JSON.parse(process.env.REACT_APP_FIREBASE_CONFIG);
|
|
// const config = {
|
|
// apiKey: "AIzaSyDPLT8GiDHDR1R4nI66Qi0BY1aYviDPioc",
|
|
// authDomain: "imex-dev.firebaseapp.com",
|
|
// databaseURL: "https://imex-dev.firebaseio.com",
|
|
// projectId: "imex-dev",
|
|
// storageBucket: "imex-dev.appspot.com",
|
|
// messagingSenderId: "759548147434",
|
|
// appId: "1:759548147434:web:e8239868a48ceb36700993",
|
|
// measurementId: "G-K5XRBVVB4S",
|
|
// };
|
|
|
|
const config = {
|
|
apiKey: "AIzaSyDSezy-jGJreo7ulgpLdlpOwAOrgcaEkhU",
|
|
authDomain: "imex-prod.firebaseapp.com",
|
|
databaseURL: "https://imex-prod.firebaseio.com",
|
|
projectId: "imex-prod",
|
|
storageBucket: "imex-prod.appspot.com",
|
|
messagingSenderId: "253497221485",
|
|
appId: "1:253497221485:web:3c81c483b94db84b227a64",
|
|
measurementId: "G-NTWBKG2L0M",
|
|
};
|
|
|
|
if (!firebase.apps.length) {
|
|
firebase.initializeApp(config);
|
|
}
|
|
|
|
export const auth = firebase.auth();
|
|
//export const analytics = firebase.analytics();
|
|
|
|
export default firebase;
|
|
|
|
export const getCurrentUser = () => {
|
|
return new Promise((resolve, reject) => {
|
|
const unsubscribe = auth.onAuthStateChanged((userAuth) => {
|
|
unsubscribe();
|
|
resolve(userAuth);
|
|
}, reject);
|
|
});
|
|
};
|
|
|
|
export const updateCurrentUser = (userDetails) => {
|
|
return new Promise((resolve, reject) => {
|
|
const unsubscribe = auth.onAuthStateChanged((userAuth) => {
|
|
userAuth.updateProfile(userDetails).then((r) => {
|
|
unsubscribe();
|
|
resolve(userAuth);
|
|
});
|
|
}, reject);
|
|
});
|
|
};
|