Closed zimt28 closed 9 years ago
@zimt28 It supports multiple rules.
The problem that you are having is that if any deny rule returns true the document will not be inserted in any case
Oh, all right.
if any deny rule returns true the document will not be inserted in any case
This is what I'd expect. However, the moment I defined two deny rules, even if both of them returned true, the document was inserted but shouldn't.
Did you do this?
https://github.com/nicolaslopezj/roles#helper-for-collections
I'm doing that manually and it's basically the same thing .. Shouldn't be a problem
### Server ###
Mongo.Collection.prototype.registerActions = ->
Roles.registerAction "#{@_name}.insert", true, false
Roles.registerAction "#{@_name}.update", true, false
Roles.registerAction "#{@_name}.remove", true, false
Mongo.Collection.prototype.addAllowRule = ->
@allow
insert: (args...) => true
update: (args...) => true
remove: (args...) => true
Mongo.Collection.prototype.addDenyRule = ->
isDenied = (collectionName, mode, args...) ->
userId = args[0]
Roles.deny(userId, "#{collectionName}.#{mode}", args...)
@deny
insert: (args...) => isDenied(@_name, 'insert', args...)
update: (args...) => isDenied(@_name, 'update', args...)
remove: (args...) => isDenied(@_name, 'remove', args...)
App.hooks.add 'collections:on:startup', (collection, name) ->
collection.registerActions()
collection.addAllowRule()
collection.addDenyRule()
Try to do it with the method that is in the docs and tell me if it works
Works now. Not sure what it was, but the problem disappeared as a re-structured my code. Great package, thanks again!
Great!
Thanks for this package, it's great!
At the moment it seems not possible to have multiple allow/ deny rules for one action. As an example, if I have multiple deny rules, they will get ignored:
So it would be great if we could set multiple allow/ deny rules. Any opinions?