문제

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

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top