I feel like there is something wrong with Firebase 3 Security Rules.
My rules look like this:
{"rules":
{
"pages": {
".read": true,
"$pageId": {
".read": true,
".write": "root.child('adminUsers').hasChild(auth.uid)"
}
},
"adminUsers": {
".read": false,
".write": false
}
}
}
Trying to add set a page object
firebase.database().ref('/pages/-KL1TmkWWNUYsMqvTw1E').set({slug: 'rule'})
Got this error (even though /adminUsers/-XXXX = true where -XXXX is my user id):
FIREBASE WARNING: set at /pages/-KL1TmkWWNUYsMqvTw1E failed: permission_denied
After changing ".write": "root.child('adminUsers').hasChild(auth.uid)" to ".write": true, it worked. But that's not what I wanted.
Tested the same thing with Rules simulator, everything's ok. I'm lost.