Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't bind document with sub references without opening the firestore rules #295

Closed
tralves opened this issue Jun 30, 2019 · 5 comments
Closed

Comments

@tralves
Copy link

tralves commented Jun 30, 2019

Using nativescript-plugin-firebase by @eddyerburgh.

I have a categories collection. Each category has an array (not a collection) of references torecipe.

I am creating the binding like this:

return bindFirestoreRef("categories", db.collection("categories"), { maxRefDepth: 1 });

In Firestore, I have the rules:

    match /categories/{document=**} {
      allow read, update: if request.auth.uid != null;
    }

    match /recipes/{document=**} {
      allow read, update: if request.auth.uid != null;
    }

In this situation, the binding will not work (bindFirestoreRef will never resolve). I don't see any errors in the console, even with a catch.

This problem is related to the rules not being applied to the sub-references.

It does work if I do one of the following:

1- I change the binding to { maxRefDepth: 0 } because it will not grab the sub-documents.

2- If I open the firestore rules with

  match /{document=**} {
    allow read, update: if request.auth.uid != null;
  }

This is very weird because I am also binding the recipes and that works with the original rules! For this reason, I think it has something to do with the way Vuexfire is binding sub-references.

Sorry, I can't dig deeper right now. Maybe I am doing something wrong?

@posva
Copy link
Member

posva commented Jun 30, 2019

I would say Vuefire is binding nested ref but rules are preventing it. The weird thing is there is no access error. Are you running a minified version of Firebase? Even though I think they report errors

@posva
Copy link
Member

posva commented Jun 30, 2019

In that case, this would be a duplicate of #281

@tralves
Copy link
Author

tralves commented Jun 30, 2019

Thank you for the quick reply. I saw that issue too, but I don't think they are the same. In that situation, the reference was to a doc that was not allowed. In my case, the referenced document (e.g /recipes/1) has the proper rules, since I am binding it too with:

  return bindFirestoreRef("recipes", db.collection("recipes"));

and it works. Testing again. Could be cache or something.

Later today I will give this another shot. I just wanted to make sure it was not a known issue.

Edit: maybe you missed it, but I am using nativescript-plugin-firebase. The problem could be there, or at least the fact that I am no seeing logs.

@posva
Copy link
Member

posva commented Jun 30, 2019

Ah yeah, it seems to be different indeed. However, I don't know where it's coming from. My guess is there is something with the SDK. If you have a repro with the JS SDK, I can take a look!

@posva
Copy link
Member

posva commented Jul 25, 2019

Closing due to inactivity. Please open a new issue with a reference to this one if you can follow up with more information.

@posva posva closed this as completed Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants