Firebase: Authorization and User data.
Firebase is a very user friendly Software Development platform that was acquired by Google in 2014. Setting up a user authorization form can be a little daunting but Firebase makes it very easy. The first step is to create a Firebase account then create a new app, select the mediums that you will be using, in the case of this blog a “web app”. Once that is done Firebase will give you the keys to the car.
Your web app’s own firebaseConfig object which stores your apiKey, authDomain(where you’re going to call and sen user input for sign up and login), your databaseURL, and some other goodies along with and initializer. This block of code needs to be copied and pasted at the bottom of your index.html file just under the <body> tag. I like to go ahead and point to what I will be using for example:
const auth = firebase.auth(); (points to the authorization domain)
const db = firebase.firestore(); (points to the Firestore database)
Once I have my pointers I will start working out creating users for my auth().
Below is a method out of the Firebase auth toolbox taking in an email and password from an html form, then once the method has taken in the values from the form it will fire a function with a resoponse(cred):
auth.createUserWithEmailAndPassword(email, password).then(cred => {
If there is more information to be saved I will take the userID from the cred(response) and call the db, make a collection(objects in firebase) with the name “users” point to the specific ID of the User, set the values, and push to the database.
return db.collection(“users”).doc(userID).set({
username:$(“#username”).val(),
});

Once that is saved the User email and password will be in the Auth Domaine and the other user input will be saved with the same userID as our created user. If I wanted to get the data for displaying on the DOM I would call the db collection of “users”, point to the specific userID and you a .get method to fetch the data, once that is done it will fire a function that returns the data:
db.collection(“users”).doc(user.uid).get().then(doc => {
userData = doc.data();
username = userData.name;