node.js - Sails: How to only authorize creation of a blueprint model -
in sails application, have created data model , controller (blueprint model).
i have set following policies authorize creation of new data.
module.exports.policies = { // prevent actions '*': false, // data controller's policies datacontroller:{ '*': false, 'create': true } }; this not work , prevent actions. not 'create' rules have priority on rules above ?
update
my mistake, datacontroller should replaced data (thanks #sailsjs irc).
i have updated policies order not working either:
module.exports.policies = { // data controller's policies data:{ 'create': true, 'find': false, 'findall': false, 'update': false, 'destroy': false } }; with code, 'create' action forbidden when 1 need open anyone.
i assume using built in blueprints sails.js provides
you find following policies allow access '/data/create' route
data: { 'find': true, 'create': true, 'update': true, 'destroy': false, 'findall': false } i unsure why policies have configured in order access 'create' route, suppose has way blueprints implemented behind scenes
a possible work around problem create own routes override default blueprints provided sails. example, mapping '/data/create' createdata method within data controller , specifying policies apply method.
my understanding these crud routes intended use during development, find stated within config/controllers.js file
// these crud shortcuts exist convenience during development, // you'll want disable them in production. // '/:controller/find/:id?' // '/:controller/create' // '/:controller/update/:id' // '/:controller/destroy/:id' as blueprints not intended used in production, writing policies target these default crud shortcuts serves no purpose. so, option disable blueprints altogether in config/controllers.js , instead apply policies own custom routes , methods.
Comments
Post a Comment