My users are sometimes affected by FirebaseFirestoreException: PERMISSION_DENIED
FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.
at com.google.firebase.firestore.util.Util.exceptionFromStatus(Util.java:117)
at com.google.firebase.firestore.core.EventManager.onError
at com.google.firebase.firestore.core.SyncEngine.removeAndCleanupTarget(SyncEngine.java:588)
at com.google.firebase.firestore.core.SyncEngine.handleRejectedListen(SyncEngine.java:424)
at com.google.firebase.firestore.core.MemoryComponentProvider$RemoteStoreCallback.handleRejectedListen(MemoryComponentProvider.java:99
My app is live for around a month and it has around 10000 users. I've received around ~25 reports so far. I have no idea what the issue can be. This is my Firestore setup:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /coupons/{coupon} {
allow read: if isAuthenticated();
}
match /users/{userId} {
allow read, update, delete: if isAuthenticated() && isOwner(userId);
allow create: if isAuthenticated();
}
function isAuthenticated() {
return request.auth != null
}
function isOwner(userId) {
return request.auth.uid == userId
}
}
}