FireStore: query the Firebase Auth table?

前端 未结 1 583
余生分开走
余生分开走 2021-01-23 00:18

I\'m building an app using Firestore, where a group of people need to be able to access an object, and I followed the guide at https://firebase.google.com/docs/firestore/solutio

相关标签:
1条回答
  • 2021-01-23 00:50

    With the client SDKs there is no way to list all the users of your Firebase project.

    On the other hand, the Admin SDK allows retrieving the entire list of users in batches, see https://firebase.google.com/docs/auth/admin/manage-users#list_all_users. Note that if you want to use this possibility offered by the Admin SDK, you need to do it from a "privileged environment" (see https://firebase.google.com/docs/admin/setup), for example with a Cloud Function. You would then need, from you front-end, to call this Cloud Function.

    However, one of the classical approach is to maintain a list of all your users in a dedicated Cloud Firestore collection. There are several advantages with this approach, among which:

    • You can easily query this list with the client SDKs;
    • You can store some extra info in the user profiles document, e.g. the user roles. As a matter of fact, with the Admin SDK's listUsers() method you get the result as UserRecord object which has a fixed list of properties.
    0 讨论(0)
提交回复
热议问题