0

Summary:

I am using Refit to do Api Rest calls to my firestore database.

Problem is I have setup rules and it looks like the 'request.resource.data' dictionary of my request is not defined.

enter image description here

My condition in the firestore rule tab is: see UPDATE part below*

(I've also tried request.resource.data......)

What I know: When I only check the auth.uid it works well but when I am adding this condition it fails.

So Question is: How can I fill this attribute? :) Thank you by advance :)

UPDATE :

Here are the concerned firestore rules:

enter image description here

enter image description here

Nearon
  • 71
  • 5
  • 2
    Can you provide a minimal example of your rules showing how the function `containsLicence` is used? Note that the `resource` variable [1] binds to the documents being read/written. If you attempt to use `resource` in the context of query (`list`), the `resource` variable will not bound at rules evaluation time. Rules are not filter [2] [1] https://firebase.google.com/docs/reference/rules/rules.firestore.Resource [2] https://firebase.google.com/docs/firestore/security/rules-query#rules_are_not_filters – Louis Kuang Dec 03 '22 at 03:49
  • Thank you for the fast reply. I updated the question. – Nearon Dec 03 '22 at 09:23
  • I decided to pass through a firebase cloud function (it works). But I am still interrested in the answer. – Nearon Dec 03 '22 at 09:31
  • Based on the updated question, are you trying to use rules to authorize a write iff the user is signed in and is the owner of the user document and the updated data contains a `licence1` key? In that case you can use `resource.data.keys().hasOnly(...)` instead of having the `request.` prefix. The `request` and `resource` variables are two different variables that provide additional context for rules evaluation. Note that using `resource` will result in one read of the affected document. See https://firebase.google.com/docs/rules/rules-language#building_conditions for more details. – Louis Kuang Dec 04 '22 at 16:19
  • Please post your code as text and not as images. – SimonC Dec 06 '22 at 11:55

0 Answers0