Firebase Authentication Service - search uid from email without login

I am building an application using Firebase, a Firebase authentication service (simple email / password login), and storing user information in a manner similar to what is described here .

Part of my function should allow me to search for another user based on my email address.

Is there an easy way to use an email to search for a given Firebase uid (ie "simpleLogin: 9") without having to repeat them to all users or be able to actually register them?

+2
source share
1 answer

Your users node is a regular node in Firebase. Thus, the only way to search for elements is either by node name or by priority of node.

If you want to use uid as the name of the node, you can set the email address as priority using setPriority or setWithPriority and then filter using startAt and endAt .

  // save new user profile into Firebase so we can // list users, use them in security rules, and show profiles myRef.child('users').child(user.uid).setWithPriority({ displayName: user.displayName, provider: user.provider, provider_id: user.id }, user.email); var userRef = myRef.child('users').startAt(user.email).endAt(user.email); 

But if you use only email, you can just save users to their email address to start with:

  myRef.child('users').child(user.email).set({ displayName: user.displayName, provider: user.provider, provider_id: user.id }); var userRef = myRef.child('users').child(user.email); 

See also:

+3
source

Source: https://habr.com/ru/post/1014114/


All Articles