How to get the email of any user in Firebase based on user id?

前端 未结 5 1685
灰色年华
灰色年华 2020-12-09 04:48

I need to get a user object, specifically the user email, I will have the user id in this format:

simplelogin:6

So I need to write a function so

5条回答
  •  无人及你
    2020-12-09 05:21

    To get the email address of the currently logged in user, use the getAuth function. For email and password / simplelogin you should be able to get the email like this:

    ref = new Firebase('https://YourFirebase.firebaseio.com');
    email = ref.getAuth().password.email;
    

    In my opinion, the password object is not very aptly named, since it contains the email field.

    I believe it is not a Firebase feature to get the email address of just any user by uid. Certainly, this would expose the emails of all users to all users. If you do want this, you will need to save the email of each user to the database, by their uid, at the time of account creation. Other users will then be able to retrieve the email from the database by the uid .

提交回复
热议问题