How to add additional information to firebase.auth()

后端 未结 3 1983
梦毁少年i
梦毁少年i 2020-11-29 10:30

How can I add extra attributes phone number and address to this data set? It seems like Firebase documentation doesn\'t specify anything about that.

I have implemen

3条回答
  •  被撕碎了的回忆
    2020-11-29 11:23

    As far as I know, you have to manage the users profiles by yourself if you want to have more fields than the default user provided by Firebase.

    You can do this creating a reference in Firebase to keep all the users profiles.

    users: {
      "userID1": {
        "name":"user 1",
        "gender": "male" 
      },
      "userID2": {
        "name":"user 2",
        "gender": "female" 
      }
    }
    

    You can use onAuthStateChanged to detect when the user is logged in, and if it is you can use once() to retrieve user's data

    firebaseRef.child('users').child(user.uid).once('value', callback)
    

    Hope it helps

提交回复
热议问题