I have Users database in which I want each authenticated user to read and update his own data. I also want to set one admin user who can read and update all the users' data in the database.
I tried doing like this - How to only allow one admin user to write Firebase Database?
But it didn't quite work.
My database structure is:
- Users
-key1
-email: xyz
-key2
-email: abc
This is what I tried. Here I added admin user in firebase auth and his auth id is say - s94ZwBcP However, I dont have any key in the database for this user (as I dont need it).
"rules": {
"users":{
"$uid":{
".read" : "$uid == auth.uid || auth.uid === 's94ZwBcP'",
".write": "$uid == auth.uid || auth.uid === 's94ZwBcP'"
}
}