Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save anioutkazharkova/72749760c3f416b0059570f94c01c4af to your computer and use it in GitHub Desktop.
Save anioutkazharkova/72749760c3f416b0059570f94c01c4af to your computer and use it in GitHub Desktop.
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