Reputation: 1249
I've applied Firebase Authentication successfully using email and password once the user login to the app.
Next, I've set the Security rules for my database with Cloud Firestore
like this.
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
Now, the user should insert something to the but only if he's an authenticated user and his info exists in the authentication table in firebase console.
..but that's not the case, I've inserted some data to the database successfully while the user wasn't authenticated. it seems like the rules are ignored..!
How exactly can I only allow read & write for authenticated users?
Upvotes: 1
Views: 1716
Reputation: 697
Try this code:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth.uid != null;
}
}
}
Upvotes: 7