Manal
Manal

Reputation: 189

The caller does not have permission to execute the specified operation

I am trying to build an app that contains chat, but the error message appears:

[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: [cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation.

My firebase rules:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
  
match /users/{uid}{
allow write: if request.auth != null && request.auth.uid == uid;
}

match /users/{uid}{
allow read: if request.auth != null;
}

match /chat/{document=**}{
    allow read: if request.auth != null;
    }
  }
}

enter image description here

as seen in the picture above, when I write a message and send it, it doesn't appear in the screen, and the error message is written in terminal

Upvotes: 3

Views: 13034

Answers (3)

Amen Adem
Amen Adem

Reputation: 11

you should update your Firestore rules try to change date for next month or year

from : request.time < timestamp.date(2022, 7, 4);

to :
request.time < timestamp.date(2022, 8, 4);

rules_version = '2';

service cloud.firestore {

  match /databases/{database}/documents {

    match /{document=**} {

      allow read, write: if

          request.time < timestamp.date(2022, 8, 4);

    }

  }

}

Upvotes: 0

kodeKhalifa
kodeKhalifa

Reputation: 330

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, 
      write: if true;
     }
  }
}

This can be used when there is no need for authentication access.

Upvotes: 1

Priyesh
Priyesh

Reputation: 1313

You can make your rule as per below. It is also secure

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth != null;
    }
  }
}

Upvotes: 9

Related Questions