gotmikhail
gotmikhail

Reputation: 893

Can you disable some blueprints on a specific controller?

Is there a known way to disable specific blueprints on the per-controller level in sails.js?

I've read how to disable ALL blueprints on the app level, and how to disable ALL blueprints for an individual controller but is there a way to disable a subset of the blueprints on an individual controller?

This documentation covers the basics, including disabling all blueprints per controller, https://github.com/balderdashy/sails-docs/blob/master/reference/blueprint-api/blueprint-api.md

But say I have a Counties model and I want the find actions available (find() and findOne()), but do not want the others.

Is that an option?

Upvotes: 4

Views: 983

Answers (1)

Mandeep Singh
Mandeep Singh

Reputation: 8224

You can override them in the controllers. For example,

  update: function (req, res) {
    res.forbidden();
  },  

  destroy: function (req, res) {
    res.forbidden();
  } 

This is one way. Other and more preferred way is to use policies:

  myController: {
    'find': true,
    'findOne': true,
    '*': false
  },

This will only expose find and findOne and hide other actions

Upvotes: 7

Related Questions