I am currently trying to set up a simple authorization system (pre-existing authentication) for sails (v0.10) based on an application on policy system boards. For this, I would need to get the controller and the action of the current request goals from my policy.
I would do something like this in politics:
module.exports = function (req, res, next) {
var target = req.target;
var action = req.action;
User.findOne...
};
I remember that the target information was embedded in the request object at some point, but was not found there now (commit 5d98ec8 ).
I know about the ability to parse req.route and get the necessary information by simulating a sail router, but I would prefer to avoid duplicating the routing logic for the sole purpose of the policy.
Edit:
:
var controller = req.options.controller || req.options.model;
req.options:
{ detectedVerb: { verb: '', original: '/user/:id?', path: '/user/:id?' },
associations:
[ { alias: 'auth', type: 'model', model: 'key' },
{ alias: 'group', type: 'model', model: 'group' },
{ alias: 'role', type: 'model', model: 'role' } ],
actions: true,
rest: true,
shortcuts: true,
prefix: '',
pluralize: false,
index: true,
model: 'user' }
- .