Domanda

Sails.js (0.9v) controllers has a *_config function* to override configs from config file.

is there any _policies function to define the policies inside the controllers itself?

Thanks

È stato utile?

Soluzione

Policies can already be specified on per-controller basis in the /config/policies.js file, so there's no benefit in having the configuration exist inside the controller file as well. See the comments inside /config/policies for information on how to attach a policy to a specific controller or action. Also keep in mind that in Sails v0.10, the _config key is still valid inside controller files, but the configuration properties should be put at the top level, not under blueprints, e.g.:

_config: {
   rest: false,
   actions: false,
   shortcuts: false
}

These will override the settings in your /config/blueprints.js file.

Altri suggerimenti

I think nope. You can override the controller config but not create policy inside it. E.g.

...
_config: {
  blueprints: {
    rest: true, ....
  }
}

Please define policies as middleware in the policies folder.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top