[Vuejs]-VueJS + Firebase: Matching Keys Between Authenticated User And Users Collection

0👍

Currently I pull the uid property off the object that resolves from calling your auth method of choice, in my case it is createUserWithEmailAndPassword, then set it on the database using the uid as a ref. I also add to that object what I currently know about the user, such as whatever OAuth gives you, or whatever your form is providing.

An example in ESNext, within an async function, and email/password auth:

const {uid} = await firebase.auth().createUserWithEmailAndPassword(email, password)

firebase.database().ref(`users/${uid}`).set({
  email,
})

Next time they log in, you can pull their user data using their uid.

At least, that’s what I’m doing. I’m also new to Firebase.

Leave a comment