[英]I can`t read the data after I update my rules on firestore (React Native)
我設置的規則是允許讀取: if resource.data.uid == request.auth.uid;
我怎么稱呼它是這樣的
return async (dispatch) => {
await firebase
.firestore()
.collection("patients")
.doc(firebase.auth().currentUser.uid)
.collection("patient")
.orderBy("creation", "desc")
.get()
.then((result) => {
let Patients = result.docs.map((doc) => {
const data = doc.data();
const id = doc.id;
return { id, ...data };
});
dispatch({ type: GET_PATIENTS, Patients });
});
};
我該如何解決?
firebase規則
match /databases/{database}/documents {
match /patients/{patientsID}{
match /patient/{patientID}{
allow read: if resource.data.uid == request.auth.uid;
allow create: if request.resource.data.uid == request.auth.uid;
allow update: if request.resource.data.uid == request.auth.uid;
allow delete: if resource.data.uid == request.auth.uid;
match /diagnostic/{diagnosticID}{
allow read: if true;
allow write: if request.resource.data.uid == request.auth.uid;
}
}
}
}
}
數據圖像
規則不會自行過濾數據。 相反,他們只是確保所請求的數據符合您的規則。
因此,您的查詢需要匹配規則,這意味着它們還需要按 UID 過濾:
.collection("patient")
.orderBy("creation", "desc")
.where("uid", "==", firebase.auth().currentUser.uid)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.