I am a student developer trying out the new Firestore in my angular app and got stuck on the security rules.
what i'm trying to achieve:
display a firestore document in an angular view using template binding. the document should be view-able to non-authenticated users.
the problem:
if a non-authenticated user tries to view the page a permissions error occurs:
ERROR Error: Missing or insufficient permissions. at new FirestoreError (error.js:164)
the template file:
<p>{{ (item | async)?.name }}</p>
the component.ts file:
interface Profile {
name: string;
}
...
private itemDoc: AngularFirestoreDocument<Profile>;
item: Observable<Profile>;
...
ngOnInit() {
this.itemDoc = this.afs.doc<Profile>('profiles/0mlC8uWaKeArzk0sfIfX');
this.item = this.itemDoc.valueChanges();
}
firestore rules:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}