jamesjwarren
jamesjwarren

Reputation: 45

Criteria permission with sails-permissions

I have created a permission with assigned criteria however it always results in a 404 Not found, suggesting there are no permitted records. As you can see from the output of the log the criteria is { group: 1 } and there is one record where group = 1 so one record should be returned yet as you can see permitted.lenth is equal to 0. Is anyone familiar with sails-permissions able to advise on whether this is correct?

Log Output

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

Upvotes: 1

Views: 182

Answers (1)

jamesjwarren
jamesjwarren

Reputation: 45

This is caused by a custom find blueprint reformatting the data structure, to add pagination meta { items: [], _pagination: {...}}. This conflicts with what sails-permissions expects from the find blueprint, which is an Array [].

Upvotes: 1

Related Questions