1

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.

Pritam Parua
  • 672
  • 2
  • 8
  • 27

1 Answers1

1

The problem is in your policies.js file :

You can try this

module.exports.policies = {
    //Your controller
    UserController: {
        '*': 'sessionAuth'
    }
};