Rules to allow admin role to read users collection

Troubleshooting

Hello everyone,

I am trying to allow admins to read user collection, in the dashboard I have a container on which I queried user collection 'count' for admins to see how many users are in a database.
Normally, it does not work, so I tried editing Firebase rules and adding the rules you can see under the question. What have you tried so far?

I also tried to change the column Read from Users Collection to Authenticated user which works but then I was not able to create an account at all nor verify



Please let me know if anyone has any suggestions on how to show Users collection count.
Thanks in advance.

What have you tried so far?
  • allow read: if request.auth.uid == document && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin';

  • allow read: if request.auth.uid == document &&

get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin' &&

request.auth.token.email_verified == true;

  • allow read: if request.auth != null &&

    request.auth.token.email_verified == true && request.auth.uid == resource.id && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin';

Did you check FlutterFlow's Documentation for this topic?
No
1
4 replies