Reputation: 189
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;
}
}
}
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
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
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
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