【问题标题】:Sails js policies not workingSails js政策不起作用
【发布时间】:2016-01-27 10:00:48
【问题描述】:

我已经在 Sails js 中编写了基本策略。

在 app/config/policies.js 中

module.exports.policies = {
   '*': 'sessionAuth'
};

在 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.');
};

但是当我请求一些 URL 时,'reach' 没有在控制台中打印,并且这个基本策略不起作用。它将执行在 route.js 中定义的控制器操作。

【问题讨论】:

    标签: javascript sails.js policies


    【解决方案1】:

    问题出在您的 policy.js 文件中:

    你可以试试这个

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

    【讨论】:

    猜你喜欢
    • 2018-07-23
    • 1970-01-01
    • 2014-05-03
    • 1970-01-01
    • 1970-01-01
    • 2017-04-15
    • 2015-06-03
    • 2017-01-12
    • 1970-01-01
    相关资源
    最近更新 更多