0

I'm making an application with a Message object which has sender and receiver properties.

I'd like to assign these properties Users that live in the Auth' tab of Firebase Console (fb auth-ed).

Since my application's functionality only needs to read data from the users, I thought I don't need to add them to the realtime database, just access them through FIRAuth (which I'm assuming is the internal representation of the Auth' tab on Firebase Console).

I can get the 'current user' like this:

FIRAuth.auth()?.currentUser

And this will be the 'sender' property of a Message.

But for the 'receiver' property I want to grab a User (that the sender will choose from a drop down of fb contacts) from the fb auth-ed ones listed in the Auth' tab of Firebase Console. For recipient, I need to be able to do something like this (pseudocode):

users.find(where uid == current_user.uid)

Is it possible to do this directly without User table(s) in database? Do I really need to copy over entries from Firebase Auth to Firebase Database? Shouldn't there be a better way to get non current users from Firebase? Does anyone else think that's really bad design (for just being able to read an entry)? Aren't I then responsible for the maintenance of those entries?

Appreciate pointers to specific reading too!

For clarity, I'm not trying to query an entry in the realtime database tab of Firebase Console. I'm trying to query the User object that Firebase saves from Facebook (which is visible in Auth' tab of Firebase Console).

Tam Borine
  • 1,474
  • 2
  • 13
  • 21
  • 1
    If you are trying to access other users information then, you need to store those value's in Database and then access them from there.. From current *`auth`* class you would only be able to access the current user's information – Dravidian Oct 30 '16 at 16:48
  • thanks @Dravidian, I do believe you and happy to try that but if you know of where in the docs it specifies that it is necessary, I'd love the link too. – Tam Borine Oct 30 '16 at 17:26
  • 1
    There is no API to get a list of users from Firebase Authentication. The typical approach is as Dravidian answered, which is covered in many questions already, including this [original one](http://stackoverflow.com/q/14673708), this [one from me](http://stackoverflow.com/q/31038611) and this [recent one](http://stackoverflow.com/q/39757121). – Frank van Puffelen Oct 30 '16 at 20:56
  • Thanks, that question does answer it, sounds like it's by design and for good security related reasons. – Tam Borine Oct 30 '16 at 22:20

1 Answers1

0

To access the other users make your JSON structure like this:-

Users:{
  userID1 : {...//PERSONAL DATA},
  userID2 : {...//PERSONAL DATA},
  userID3 : {...//PERSONAL DATA}
  },
users_Data:{
    userID1 : {...//data to be shared like userID, name..etc},
    userID2 : {...//data to be shared like userID, name..etc},
    userID3 : {...//data to be shared like userID, name..etc}
 } 

Just access those users_Data to store in your dataSource in which you will have your usersID's to access.

Dravidian
  • 9,945
  • 3
  • 34
  • 74