I want to check for the UID stored in the document field of a document (of the parent collection named premiumID) against the UID of the user requesting the data. In simpler words, I want the user to only access the document which contains his UID.
Here's what I have done until now
service cloud.firestore {
match /databases/{database}/documents {
match /premiumID/{docId} {
function userData() {
return resource.data.uid
}
allow update: if userData() == request.auth.uid;
allow delete: if userData() == request.auth.uid;
allow create: if request.auth.uid != null;
allow read: if userData() == request.auth.uid;
}
}
}
Here's what my DB looks like-
Here's how I am testing it. This gives me read and write denied.

