Orionjs-博客示例-用户无法更新帖子中的任何属性

Orionjs - Example blog - users not able to update any of the attributes in the post

本文关键字:更新 属性 任何 用户 Orionjs-      更新时间:2023-09-26

我正在这里试用流星的orionjs CMS包中的blog示例-https://github.com/orionjs/examples.

在本例中,社区用户可以创建/删除(他们自己的)帖子,但不能更新帖子的任何属性。

根据orion/roles/community.js,用户应该能够通过更新除createdBy之外的任何属性

/**
 * Users can update posts
 */
CommunityRole.allow('collections.posts.update', function(userId, doc, fields, modifier) {
  return doc.createdBy === userId; // Will be allowed to edit his own posts
});
/**
 * Users can't change the createdBy attribute
 */
CommunityRole.deny('collections.posts.update', function(userId, doc, fields, modifier) {
  return !_.contains(fields, 'userId');
});

在github中也提出了同样的问题-https://github.com/orionjs/examples/issues/16

orion创建者已经修复了原始代码中的一个错误。在orion/roles/community.js中,这需要更改

return !_.contains(fields, 'userId');

return _.contains(fields, 'userId');