A
A
Alexis_D2020-10-08 17:21:45
React
Alexis_D, 2020-10-08 17:21:45

How to add additional information when registering in firebase?

Good day, how can I, when registering a new user in firebase, add a phone field or any other field I need (be it a type of something)

await app.auth().createUserWithEmailAndPassword(event.email, event.password)

This method is working, but it only allows you to add an email and password to the user, but there are no other fields.
Maybe someone has links where you could read it or there is a ready-made method
Thanks in advance for your answer

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aleks_Ko, 2020-10-14
@Alexis_D

Good afternoon
And if you add an email and a password like yours during registration,

await firebase.auth().createUserWithEmailAndPassword(email, password)

then determine the uid
and use it to add all the necessary fields already in database()
await firebase.database().ref(`/users/${uid}/userInfo`).set({
                  name, department, email
              });

This is what my full version looks like in vuex
actions: {
async registrations({commit, dispatch}, {name, department, email, password}){
          try{
              await firebase.auth().createUserWithEmailAndPassword(email, password)
              const uid = await dispatch('userId');  
              await firebase.database().ref(`/users/${uid}/info`).set({
                  name, department, email
              });
          }catch(e){
              throw e
          }
        },
       userId(){
          const user = firebase.auth().currentUser
          return user ? user.uid : null
        }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question