A module that simplifies the usage of Firebase's email and password login as well as the email link method.
npm install firemaker --save
// Initializing Firebase
var config = {
apiKey: "<API_KEY>",
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
projectId: "<PROJECT_ID>",
storageBucket: "<BUCKET>.appspot.com",
messagingSenderId: "<SENDER_ID>",
};
firebase.initializeApp(config);
// This ensures that your app is ready for Firemaker!
import Firemaker from 'firemaker'
Firemaker('local').signUp('email', 'password')
.then(() => { // Promise based
// Do what you need to here
});
// Remember that your app needs to be initialized with your console config and activated in Firebase console
import Firemaker from 'firemaker'
Firemaker('local').signIn('email', 'password')
.then(() => {
// Do what you need to here
})
This requires you to pass you actionCodeSettings as a third parameter, and also you can leave the second parameter as _
import Firemaker from 'firemaker'
const actionCodeSettings = {
url: 'http://localhost:8080',
handleCodeInApp: true
};
// The first parameter is the email to send the link to.
Firemaker('emailLink').signUp('example@mail.com', _, actionCodeSettings);
import Firemaker from 'firemaker'
// Important to specify your strategy
Firemaker('local').getUser()
// Optios can be added in the returned user eg. 1)
// Returns full user object from Firebase
.then((user) => console.log(user));
// Eg 2)
// Returns user with display name
.then((user) => console.log(user.displayName));
// Eg 3)
// returns the unique id of the user
.then((user) => console.log(user.uid));
// Eg 4)
// Returns the logged in user's email
.then((user) => console.log(user.email));
// There are other properties available on the object
// Available on Firebase