-
Notifications
You must be signed in to change notification settings - Fork 183
Description
Hi Onury,
Really like what you did with this library 👍 .
I have a question for you. If I have a permission structure like this:
[
{ role: 'admin', resource: 'user', action: 'create:any', attributes: ['*'] },
{ role: 'admin', resource: 'user', action: 'read:any', attributes: ['*'] },
{ role: 'admin', resource: 'user', action: 'update:any', attributes: ['*'] },
{ role: 'admin', resource: 'user', action: 'delete:any', attributes: ['*'] },
{ role: 'user', resource: 'user', action: 'read:own', attributes: ['*'] },
{ role: 'user', resource: 'user', action: 'update:own', attributes: ['*'] },
{ role: 'user', resource: 'user', action: 'delete:own', attributes: ['*'] },
]And in my controller, I do a check for can(role).readOwn(resource)... if the user I am checking on has a role of admin does the code assume that because admin's have access to read:any they can also read:own?
That is what I am seeing happen in my debugger, which makes sense to me. I just want to confirm that is happening?
For instance, if I am logged in as an admin and a run a check for can(role).readOwn(resource), I am returned TRUE from granted, even though I did not specifically state an admin can read:own in my permissions above.
I ask because in another question I see that you suggest the following:
var role = req.user.role;
// check if the request is for own photos or any
var permission = (req.user.name === req.params.username)
? ac.can(role).updateOwn('photo')
: ac.can(role).updateAny('photo');Is this necessary or can I just check ac.can(role).updateOwn('photo')?
Thanks!