In my application I use custom claims to assign roles to users. The admin can change the roles of people with a snazzy toggle button (using a cloud function), so (s)he needs to see a list of all of the users... But on the other hand when a user registers they need to be added to the users database collection. This collection isn't used to authorize anything obviously, but it's just so that the admin can change the roles for the users in that collection. So the admin needs to be able to read the table and everyone needs to be able to write in the collection.... So my rules in this regard look like this:
{
"rules": {
"users": {
".read": "auth.token.isAdmin === true",
".write": true
},
I have checked in the redux store and it seems to work. I call the action creator fetching the users in a component and access it when I'm a regular user and I see that the users node in redux store remains empty... When I'm logged in as admin and go to the component I see that the users node is filled... So it seems to work, but I want to be sure this is a safe way of working, because having everyone writing to the table just feels wrong :-) But like I said, the table itself isn't used to authorize anything, so perhaps it's ok.....
Thanks for any opinions on this :-)
With kind regards, David