Created
March 12, 2023 14:50
-
-
Save anioutkazharkova/72749760c3f416b0059570f94c01c4af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rules_version = '2'; | |
service cloud.firestore { | |
match /databases/{database}/documents { | |
function signedIn() { | |
return request.auth.uid != null; | |
} | |
match /users/{user} { | |
allow read, write: if (signedIn() == true); | |
} | |
match /posts/{post} { | |
allow read: if (signedIn() == true); | |
allow write: if (signedIn() == true); | |
allow update: if ((request.auth != null && request.auth.uid == request.resource.data.userId) || | |
request.resource.data.diff(resource.data).affectedKeys() | |
.hasAny(['likeItems', "comments"])); | |
} | |
match /posts/{post}/comments/{comment} { | |
allow read, write: if (signedIn() == true); | |
} | |
match /comments/{comment} { | |
allow read, write: if (signedIn() == true); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment