I can`t read the data after I update my rules on firestore (React Native)

Tags: , , ,

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
      .orderBy("creation", "desc")
      .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:

  .orderBy("creation", "desc")
  .where("uid", "==", firebase.auth().currentUser.uid)

Source: stackoverflow