2

I saw some older question regarding this topic, but I wanted to check if during the years something changed.

I am building a friend system in Swift. There I have a list if users, that confirmed the friendrequest.

In the userData for each registered user, I have a field 'friends', that shows the confirmed friends with a Bool-value:

UserData:
    - friends:
        - UID1 : true
        - UID2 : true
        [...]

In my list, I want to show now the email of the friends, not the UID. Is there a way to get the the email by something like Auth.auth().getMailByUid()? Right now it feels very fiddly, to get the whole userData-Collection of each friend and extract the email from there. It also feels like a duplicate to save the mailadress separately in the userData, because it is already linked with the UID in the Authentication system of Firebase.

What would be the common way to achieve that?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

1

The client-side Firebase SDKs don't expose a way to look up user data by their UID as it would be a security risk. Nothing has substantially changed in this field, mostly because there isn't anything to change.

If you app needs this functionality you can either write the data into the database (and secure it there) or wrap the Admin SDK (which does have a method for this) in a custom API (and secure it there).

Also see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807