Я пытаюсь настроить правила в Firestore, где каждый может читать содержимое друг друга, если они аутентифицированы в приложении, но только владельцы документов могут создавать, писать, обновлять или удалять их.
Я установил следующие правила в Firestore:
rules_version = '2';
service cloud.firestore {
match /databases/{database} {
match /codes/{userID} {
allow create, write, update, delete: if request.auth.uid == userID;
allow read: if request.auth.uid != null;
}
}
}
Моя структура Firestore:
Collection 'codes' > Document 'BNhBibYZ0ThCNCH2gzPRufFsIk22' > nothing in here
Мой запрос:
firestore()
.collection('codes')
.doc(this.state.userID)
.onSnapshot((querySnapshot) => {
if (!querySnapshot) {
let testObj = {"hello": "world"}
firestore().collection('codes').doc(this.state.userID).set(testObj);
}
});
Вывод, который я получаю: Error: [firestore/permission-denied] The caller does not have permission to execute the specified operation.
Что я делаю не так?