Ryszard
Ryszard

Reputation: 53

Firestore request.time. toMillis() not returning a number in milisec

I tried everything but I can't get this security rule to work. I run 'get' in Simulator for path 'posts/post-1-id', where resource.data.time is time in milisce from epoch 1528316285901, which is a number.

Basically I tried all the configurations <, >, !=, ==, <=, >= just to try pass the security rule using request.time but I will alway get 'Simulated data access denied'.

How to compare data from resource.data.time in milisec to request.time ? Or how to just compare date of creation of document to request.time?

match /posts/{id} {
      allow read: if request.time.toMillis() > resource.data.time;
    } 

Upvotes: 2

Views: 648

Answers (1)

rob
rob

Reputation: 18513

This would appear to be a bug with the simulator. I'm am having the same issue from the simulator and I see the error Property time is undefined on object. You rules look like they should work though.

Note that testing your rules without the simulator is very difficult as it can take up to 10 minutes to publish new rules and during that 10 minutes requests may randomly be handled by your new or old rules.

Upvotes: 1

Related Questions