Reputation: 3971
I'm searching to add a rule in my Firestore database.
The rule is to allow write documents if the document equal the request.auth.uid
.
I don't know how to search the name of my document in the rules.
This is my code where is missing this part :
service cloud.firestore {
match /databases/{database}/documents {
match /users/{anyDocument} {
allow write: if request.auth != null && request.auth.uid == ?????????;
allow read
}
}
}
Upvotes: 1
Views: 1115
Reputation: 42048
It's unclear in your question, but I'm assume you want to enforce only writing a document who's id is equal to the users auth id.
match /users/{anyDocument} {
Because of this line, the document id will be set to the variable anyDocument
, so this is what you want to check.
allow write: if request.auth != null && request.auth.uid == anyDocument;
Upvotes: 5