Skip to content

Commit 06093ac

Browse files
committed
fix: do not allow users to edit the nextDigestAt timestamp - this should only be changed by automatic processes or we risk abuse of the system
1 parent d19b4ab commit 06093ac

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

firestore.rules

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ service cloud.firestore {
2929
function doesNotChangeRole() {
3030
return !request.resource.data.diff(resource.data).affectedKeys().hasAny(['role'])
3131
}
32+
function doesNotChangeNextDigestAt() {
33+
// Only admins/automatic processes should be able to change the
34+
// email digest notification times
35+
return !request.resource.data.diff(resource.data).affectedKeys().hasAny(['nextDigestAt'])
36+
}
3237
// either the change doesn't include the public field,
3338
// or the user is a base user (i.e. not an org)
3439
function validPublicChange() {
@@ -47,7 +52,7 @@ service cloud.firestore {
4752

4853
// Allow users to make updates except to delete their profile or set the role field.
4954
// Only admins can delete a user profile or set the user role field.
50-
allow update: if validUser() && doesNotChangeRole() && validPublicChange()
55+
allow update: if validUser() && doesNotChangeRole() && validPublicChange() && doesNotChangeNextDigestAt()
5156
}
5257
// Allow querying publications individually or with a collection group.
5358
match /{path=**}/publishedTestimony/{id} {

0 commit comments

Comments
 (0)