|
@@ -42,6 +42,33 @@ Websites.allow({
|
|
|
|
|
|
}
|
|
|
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ * Access check for update operations. NOT SAFE: needs deeper modifier checks.
|
|
|
+ *
|
|
|
+ * @param {String} userId
|
|
|
+ * The user attempting the modification.
|
|
|
+ * @param {Object} doc
|
|
|
+ * The original document to modify.
|
|
|
+ * @param {Array} fields
|
|
|
+ * The list of affected fields.
|
|
|
+ * @param {Object} modifier
|
|
|
+ * The MongoDB update modifier.
|
|
|
+ * @returns {boolean}
|
|
|
+ * True to allow update.
|
|
|
+ */
|
|
|
+ update: function (userId, doc, fields, modifier) {
|
|
|
+ if (!userId) {
|
|
|
+ throw new Meteor.Error("logged-out", "User must be logged to vote on a site.");
|
|
|
+ }
|
|
|
+ const orderedFields = fields.sort();
|
|
|
+ if (!_.isEqual(orderedFields, ["minus", "plus"])) {
|
|
|
+ throw new Meteor.Error("invalid-field", "May only update minus and plus.");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
});
|