1

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

Arif
  • 315
  • 2
  • 10

2 Answers2

2

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.

sgress454
  • 24,870
  • 4
  • 74
  • 92
0

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.

DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601