简体   繁体   中英

How can Sails.js hook routes be wired to policies?

When defining routes in a Sails.js hook in routes.after , it appears that these routes are added after the policies are bound to routes.

Does anyone know how such routes can be made to honour the polices?

The use-case is a hook that represents a pluggable behaviour such as a "blog" hook that adds it's own routes and models to the main application.

To configure policies inside your hook, you can use sails.config.policies.

module.exports = function(sails){
    return {
        configure: function(){
            sails.config.policies = {
                '*': false
            };
        },
    };
};

Although, if you want to do something async, you would need to use loadModules or initialize instead of configure, but it doesn't work properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM