Reputation: 1427
In order to create a many-to-many association between models, I use the blueprints to access something like:
/api/item/1/tags/2
How can I protect this action using policies?
This action doesn't seem to fit any of the find/create/update/destroy policies.
Upvotes: 0
Views: 1023
Reputation: 101
check this:
module.exports.routes = {
//Set blueprints
'GET /findAllUsers': {model: 'user', blueprint: 'find'},
'GET /user/findAll': {blueprint: 'find'}
'GET /user/findAll': {blueprint: 'find', model: 'pet'}
// Set policies in routes
'/foo': {policy: 'myPolicy'}
// Mix of blueprints and policies
'GET /mix-of-both': [
{policy: 'isLoggued'},
{blueprint: 'find', model: 'tag'}
]
}
Check the official docs: http://sailsjs.org/#/documentation/concepts/Routes/RouteTargetSyntax.html
I hope it helps!
Upvotes: 1
Reputation: 24948
There's no need for custom routing here; the blueprint you're referring to is called populate
, so it can be protected in your config/policies.js
with:
ItemController: {
populate: 'somePolicy'
}
Upvotes: 5