I have this React Native app that closely resembles the TikTok app, so in my Main Feed Component there is an overlay with the like button and avatar. Here is my issue:
When I go to press the heart, firestore throws a warning
console warning from Firebase
and rejects the Promise. The original contestSubmission(the video(parent component) that the overlay resides in/on is owned by the content creator. We are trying to allow any authenticated user to write to the owners Likes collection and the Likes' sub collection usersThatLiked[].
Here are a few of the firestore rules that I have tried so far.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Allow public read access, but only content owners can write
match /user/{uid} {
allow read: if true;
allow write: if request.auth.uid == uid
}
match /rockContestSubmissions/{document} {
allow read: if true;
allow write: if request.auth.uid == request.resource.data.creator
}
match /popContestSubmissions/{document} {
allow read: if true;
allow write: if request.auth.uid == request.resource.data.creator
}
match /hiphopContestSubmissions/{document} {
allow read: if true;
allow write: if request.auth.uid == request.resource.data.creator
}
match /countryContestSubmissions/{document} {
allow read: if true;
allow write: if request.auth.uid == request.resource.data.creator
}
match /mainFeed/{document} {
allow read: if true;
allow write: if request.auth.uid == request.resource.data.creator
}
match /rockContestSubmissions/{document}/{likes}/{usersThatLiked} {
allow read: if true;
allow write: if request.auth.uid
}
match /popContestSubmissions/{document}/{likes}/{usersThatLiked} {
allow read: if true;
allow write: if request.auth.uid
match /hiphopContestSubmissions/{document}/{likes}/{usersThatLiked} {
allow read: if true;
allow write: if request.auth.uid
}
match /countryContestSubmissions/{document}/{likes}/{usersThatLiked} {
allow read: if true;
allow write: if request.auth.uid
}
match /mainFeed/{document}/{likes}/{usersThatLiked} {
allow read: if true;
allow write: if request.auth.uid
}
}
}
}
and
service cloud.firestore {
match /databases/{database}/documents {
// Allow public read access, but only content owners can write
match /user/{uid} {
allow read: if true;
allow write, delete: if request.auth.uid == uid
}
match /rockContestSubmissions/{document} {
allow read: if true;
allow write, delete: if request.auth.uid == request.resource.data.creator
}
match /popContestSubmissions/{document} {
allow read: if true;
allow write, delete: if request.auth.uid == request.resource.data.creator
}
match /hiphopContestSubmissions/{document} {
allow read: if true;
allow write, delete: if request.auth.uid == request.resource.data.creator
}
match /countryContestSubmissions/{document} {
allow read: if true;
allow write, delete: if request.auth.uid == request.resource.data.creator
}
match /mainFeed/{document} {
allow read: if true;
allow write, delete: if request.auth.uid == request.resource.data.creator
}
match /rockContestSubmissions/{document}/{likes=**} {
allow read: if true;
allow write, delete: if request.auth.uid
}
match /popContestSubmissions/{document}/{likes=**} {
allow read: if true;
allow write, delete: if request.auth.uid
}
match /hiphopContestSubmissions/{document}/{likes=**} {
allow read: if true;
allow write, delete: if request.auth.uid
}
match /countryContestSubmissions/{document}/{likes=**} {
allow read: if true;
allow write, delete: if request.auth.uid
}
match /mainFeed/{document}/{likes=**} {
allow read: if true;
allow write, delete: if request.auth.uid
}
}
}
and, lastly
service cloud.firestore {
match /databases/{database}/documents {
// Allow public read access, but only content owners can write
match /user/{uid} {
allow read: if true;
allow write: if request.auth.uid == uid
}
match /rockContestSubmissions/{document=**} {
allow read: if true;
allow write: if request.auth.uid
}
match /popContestSubmissions/{document=**}{
allow read: if true;
allow write: if request.auth.uid
}
match /hiphopContestSubmissions/{document=**} {
allow read: if true;
allow write: if request.auth.uid
}
match /countryContestSubmissions/{document=**} {
allow read: if true;
allow write: if request.auth.uid
}
match /mainFeed/{document=**} {
allow read: if true;
allow write: if request.auth.uid
}
}
}
here is what that data is structured like
CloudFirestore data structure

Here are the rules that I have tried: