Comparing resource and request resource in firestore

Viewed 1673

I have a simple firestore rule:

allow update: if request.resource.data.reservedBy == resource.data.reservedBy;

my payload in the simulator is

{"name":"/databases/(default)/documents/books/I3dbzzwGJGXnqMQBOxoP","data":{"reservedBy":"Ivanko"}}

and the method is "update". The value of the field 'reservedBy' is completely different in the actual record.

No matter what I do, no matter what i change the payload to, the rule will always return true and allow the update. Is that a bug or am i missing something. Interestingly, if I change "update" to "create", the rule works as expected. Anyone else encountered this?

Thanks.

2 Answers

Just got an answer from the Firebase team saying that it is indeed a simulator bug, and that the rule should work in production.

Related