我已经创建了具有分配条件的权限,但是它始终导致404 Not found,这表明没有允许的记录。从日志的输出中可以看到,criteria{ group: 1 },并且其中有一条记录group = 1,因此应该返回一条记录,因为您可以看到permitted.lenth等于0。熟悉sails-permissions的人是否能够建议这是否正确?

日志输出

silly: PermissionPolicy: 1 permissions grant read on Issue for johnsmith
info: responsePolicy
silly: data [ { items:
      [ { owner: 1,
          group: 1,
          id: 1,
          title: 'An important issue',
          open: true,
          createdAt: '2015-08-24T18:17:32.580Z',
          updatedAt: '2015-08-24T18:17:32.586Z' },
        { owner: 3,
          group: 2,
          id: 2,
          title: 'An issue belonging to another group',
          open: true,
          createdAt: '2015-08-24T18:17:32.582Z',
          updatedAt: '2015-08-24T18:17:32.582Z' } ],
     _pagination: { current: 1, limit: 30, items: 2, pages: 1 } } ]
silly: options undefined
silly: criteria! [ { where: { group: 1 },
     permission: 45,
     createdAt: '2015-08-24T18:10:36.891Z',
     updatedAt: '2015-08-24T18:10:36.891Z',
     id: 1 } ]
silly: permitted.length === 0

最佳答案

这是由自定义find蓝图重新格式化数据结构以添加分页元{ items: [], _pagination: {...}}引起的。这与sails-permissions从查找蓝图(即数组[])中获得的期望相冲突。

10-05 21:06
查看更多