Reputation: 692
I have written a basic policies in Sails js.
in app/config/policies.js
module.exports.policies = {
'*': 'sessionAuth'
};
in app/api/policies/sessionAuth.js
module.exports = function(req, res, next) {
console.log('reach');
if (req.session.authenticated) {
return next();
}
return res.forbidden('You are not permitted to perform this action.');
};
But when i am requesting some URL, 'reach' is not printing in console and this basic policies is not working. It is going to that controller's action which is define in route.js.
Upvotes: 1
Views: 808
Reputation: 31
The problem is in your policies.js file :
You can try this
module.exports.policies = {
//Your controller
UserController: {
'*': 'sessionAuth'
}
};
Upvotes: 1