the rules I set is allow read: if resource.data.uid == request.auth.uid;
how I call it is like this
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 });
});
};
How can i fix it?
firebase rule
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;
}
}
}
}
}
image for the data
Rules don't filter data on their own. Instead they merely ensure that the data that is being requested matches your rules.
So your query needs to match the rules, which means they also need to filter by UID:
.collection("patient")
.orderBy("creation", "desc")
.where("uid", "==", firebase.auth().currentUser.uid)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.