将安全性配置为仅允许某些用户更新条目,但允许在 Backand 中读取所有条目



是否可以配置表的安全性,只允许数据库表中条目的某些用户(所有者)修改该条目?

例如,在笔记ap中,每个笔记都分配给拥有此笔记的用户列表。所有用户都应该能够看到所有注释,但只有此节点的所有者才能编辑/删除此注释条目。

我只找到了一个解决方案来过滤谁可以看到笔记,但不能过滤谁可以编辑笔记。

您需要为此创建一个操作。转到"操作"表。选择"更新期间"事件。这是取自 https://github.com/backand/todos-with-users

// if the current user has an *Admin* role then he is allowed to update a todo for other users
  if (userProfile.role == "Admin")
    return {};
  if (!dbRow.created_by)
      throw new Error('Todo with no creator can't be updated.');
  // do not allow users to change the created by field 
  if (dbRow.created_by !=  userInput.created_by)
      throw new Error('You can't change the creator of the todo.');
  // do not allow non *Admin* users to change the creator of the todo 
  if (dbRow.created_by != userProfile.userId)
      throw new Error('You can only update your own todo.');
  return {};

最新更新