I've whittled this down to the simplest example I can.
1] I have enabled Email & Password Authentication. There is a user in there with a user ID of 2, which means the user's uid will be 'password:2'.
2] The contents of my Firebase looks like this:
"password:2" : "bjB2LRQS1"
3] My security rules look like this:
".write": "newData.exists() && root.child('map').child(auth.uid).val() == newData.child('someKey').val()"
4] In the simulator, I do the following:
- Custom auth: {id: 2, provider: 'password', uid: 'password:2'}
- Simulate write
- URL field is: /a/b/c
- JSON data is: {"someKey": "bjB2LRQS1", "time":{".sv":"timestamp"}}
5] That should work, right? Nope. Because apparently "auth.uid" isn't a string! Here's what the simulator says:
Attempt to write {"someKey":"bjB2LRQS1","time":1423016690383} to /a/b/c with auth=null
/
/a
/a/b
/a/b/c:.write: "newData.exists() && root.child('map').child(auth.uid).val() == newData.child('someKey').val()"
6:66: child() expects a string argument.
=> false
No .write rule allowed the operation.
Write was denied.
Any ideas about what am I doing wrong?
Thanks for your help!
- Ab Scond