【发布时间】:2018-12-06 10:06:58
【问题描述】:
我编写了一些与默认规则完美配合的代码。代码是这样的:
function listenerNewMessages(chats) {
chats.forEach(function(item) {
db.collection("pm").doc(chats[0]).collection('messaggi')
.onSnapshot(function(snapshot) {
snapshot.docChanges().forEach(function(change) {
if (change.type === "added" && change.doc.data().idUser != idUser && (String(Date.now()) > change.doc.id && dateChat < change.doc.id) && idChat != item) {
//alert('hai ricevuto un nuovo messaggio in '+ item)
$('#contact-'+item).removeClass('flash')
setTimeout(function(){
$('#contact-'+item).addClass('flash')
}, 50);
}
})
})
})
}
但是如果我使用这些规则
service cloud.firestore {
match /databases/{database}/documents {
match /pm/{pm} {
allow read, write: if request.auth.uid == resource.data.partecipanti.partecipante1 || request.auth.uid == resource.data.partecipanti.partecipante2;
}
}
}
我明白了
Uncaught Error in onSnapshot: Error: Missing or insufficient permissions.
我做错了什么?
【问题讨论】:
-
不要删除并重新发布相同的问题。这可能会导致问题被禁止。 stackoverflow.com/help/question-bans
-
不是同一个问题
-
改为编辑原始问题(如果没有答案)
标签: javascript firebase google-cloud-firestore