Reputation: 1274
I'm using Firestore for my project and it seems to have some collection reference error.
ERROR FirebaseError: Missing or insufficient permissions. at new FirestoreError (localhost:4200/vendor.js:66703:28)
Iv' used Angular Firebase in the past and it seems like I'm doing the same thing as I did last time.
my query is very simple and its looks like that
public getUsers(): Observable<any> {
return this.afs.collection('users').valueChanges();
}
I didnt make any changes for the Database rules
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
}
}
Do you have any idea why is that keep hapening?
Upvotes: 5
Views: 12373
Reputation: 31
You need change the Database rules if you like allow all permissions to everyone. (It's unsafe, recommended only for development environment.)
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
or
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
if you need read and write in the database only for login users.
More informatión https://firebase.google.com/docs/firestore/security/get-started
Upvotes: 3
Reputation: 157
You could change 'false' to 'true'. It will allow read/write access to all users under any conditions but NEVER use this rule set in production; it allows anyone to overwrite your entire database.
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
Upvotes: 6
Reputation: 1274
As the comment above said, I've changed the false to true in the database rules
Upvotes: 1
Reputation: 317332
/databases/users can't possibly be the path of a collection in your database, since collections can only have an odd number of path components. What you have right now looks like a document reference.
If you have a collection called "users", then the collection reference just looks like this:
this.afs.collection('users')
"databases" is not part of that path. That's just used with security rules.
Upvotes: 1