我的聊天记录显示缺少权限或权限不足,无法阅读我的聊天应用程序中的消息。聊天是邀请集合的子代,它的消息带有以下界面:
界面:
export interface Bericht {
sender_uid: string;
sender_name: string;
receiver_uid: string;
receiver_name: string;
date: string;
timestamp: any;
message: string;
read: boolean;
invite_id: string;
message_id: string;
}
Firestore规则:
service cloud.firestore {
match /databases/{database}/documents {
match /invites/{invite_id} {
allow list: if isSignedIn();
allow delete: if isOwner(existingData().sender_uid) || isOwner(existingData().receiver_uid);
allow create, update: if isOwner(incomingData().sender_uid) || isOwner(incomingData().receiver_uid);
match /chat/{message_id} {
this line needs a fix ---> allow read: if isOwner(existingData().sender_uid) || isOwner(existingData().receiver_uid) || isOwner(incomingData().receiver_uid) || isOwner(incomingData().receiver_uid);// <---- this line needs a fix
allow create, update: if isOwner(incomingData().sender_uid) || isOwner(incomingData().receiver_uid);
}
}
// auth function
function isOwner(uid) {
return request.auth.uid == uid;
}
// data functions
function existingData() {
return resource.data;
}
function incomingData() {
return request.resource.data;
}
}
}