sails-permissions grant not working with criteria

126 views Asked by At

I have setup sails permissions and its working well. I only seem to have an issue when trying to grant a role access to read on a criteria.

Exact what I am trying to achieve is the following: - Users in role Public should be able to read / view any menu in menu model where the attribute 'status' is set to 'approved'.

PermissionService.grant({action: 'read', model: 'Menu', role: 'public', criteria: [ { where:{ status: 'approved'}}]})

I assume there is something wrong in my syntax, but it seems to accept it. After running the command, i get 500 error message after... after restarting sails, it shows 404.

Has anyone seen this before, or could validate my syntax?

1

There are 1 answers

0
Rakesh On

Try to add .then(console.log).catch(console.log) after your statement so it becomes:

PermissionService.grant({action: 'read', model: 'Menu', role: 'public', criteria: [ { where:{ status: 'approved'}}]}).then(console.log).catch(console.log);

This will show you some more information about the error and help you debug. Post the error here too!