浏览代码

Commit 8-3: Only allow changing certain fields of posts.

Frederic G. MARAND 9 年之前
父节点
当前提交
6c80258167
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      lib/collections/posts.js

+ 7 - 0
lib/collections/posts.js

@@ -21,6 +21,13 @@ Posts.allow({
   }
 });
 
+Posts.deny({
+  update: function (userId, post, fieldNames) {
+    // _.without() is like PHP array_diff($source, ...$keys).
+    return (_.without(fieldNames, "url", "title").length > 0);
+  }
+});
+
 // This is in lib/ instead of server/ for latency compensation.
 Meteor.methods({
   postInsert: function(postAttributes) {