accesscontrol icon indicating copy to clipboard operation
accesscontrol copied to clipboard

Permission for everything apart from self

Open tomislav12 opened this issue 7 years ago • 1 comments

Is there an option to set-up accesscontrol that some group of users, lets say Moderators, can only create resource for everybody else, but not for themselves? Currently I did it like this: { role: 'moderator', resource: 'thing', action: 'create:any', attributes: 'createAnyButNotOwn' }, and then when checking for own:

let permission = null;
if (owned) {
 permission = ac.can( user.role ... etc );
 if (permission.attributes.indexOf('createAnyButNotOwn') > -1) {
            permission = false;
          }
}

Is there a better way? Thanks

tomislav12 avatar Feb 25 '19 10:02 tomislav12

@onury is this supported currently by the library? looks like this is a nice workaround though 😄

iolivia avatar Apr 01 '19 09:04 iolivia