Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you disable some blueprints on a specific controller?

Tags:

sails.js

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?

like image 497
gotmikhail Avatar asked Mar 17 '23 21:03

gotmikhail


1 Answers

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

like image 154
Mandeep Singh Avatar answered Apr 29 '23 07:04

Mandeep Singh