I am trying to send all the permissions for an authenticated user via JSON from Sails.
My current code to find permissions for a single model type:
hasPermission: function hasPermission(req, res) {
var permitted = PermissionService.isAllowedToPerformAction({
method: req.param('method'),
model: sails.models[req.param('model')],
user: req.user
});
return res.json(200, { permitted: permitted });
}
This code doesn't work as isAllowedToPerformAction
wants a single instance of a model. Is there a way to return a single JSON file accounting for all permissions?
Ex.
You can examine the role and related permissions and users,
See more @ sails-permissions-by-example
See how to get user permissions with code in comment given by skrichten on May 10, 2014 .