so I’ve published the following security rule
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /Users/{UserId} {
allow read: if request.auth!=null && request.auth.uid == UserId;
allow write: if request.auth !=null && request.auth.uid == UserId;
}
}
When I tested this in the simulator, the read and write operations work as expected. When I go to my Flutter app and go to profile page, it returns an error and if I go to the logs I see:
W/Firestore(24658): (25.0.0) [Firestore]: Listen for Query(target=Query(Users order by name);limitType=LIMIT_TO_FIRST) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
Please help because the rule is correct but a user is still locked out.
So I tried another rule which would achieve the same thing which is:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /Users/{UserId} {
allow read: if request.auth!=null && request.auth.uid == resource.data.uid;
allow write: if request.auth !=null && request.auth.uid == UserId;
}
}
the simulator passes it but in the app I get the same error code.
Mthomas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1