You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have 3 roles: member, admin, owner. where the owner can update all user records, and admin can update all user records BUT the owner record. The reasoning is simply that the account owner can create admins in the app who shouldn't have powers to oust the owner.
Is there a recommended technique to express this tree of permissions?
If not, my suggestion is the following:
ac.grant('owner').updateAny('user')
ac.grant('admin').updateAny('user').where('/role neq "owner"') // possible with the help of spleen
// or with sift.js
ac.grant('admin').updateAny('user').where({ role: { $neq: 'owner' }})
Normal check:
let permission = ac.can('admin').updateAny('user');
permission.granted // true
If the target resource / user is supplied as second argument to can(role, data), the where clause is invoked:
I believe this new feature will unleash a wide range of new capabilities previously not possible, including the new ways to check possession internally!
The text was updated successfully, but these errors were encountered:
I think this concern has been addressed in the docs.
// user role inherits viewer role permissions
ac.grant('user').extend('viewer');
// admin role inherits both user and editor role permissions
ac.grant('admin').extend(['user', 'editor']);
// both admin and superadmin roles inherit moderator permissions
ac.grant([ 'owner']).extend('admin');
@onury
I have 3 roles: member, admin, owner. where the owner can update all user records, and admin can update all user records BUT the owner record. The reasoning is simply that the account owner can create admins in the app who shouldn't have powers to oust the owner.
Is there a recommended technique to express this tree of permissions?
If not, my suggestion is the following:
Normal check:
If the target resource / user is supplied as second argument to
can(role, data)
, the where clause is invoked:I believe this new feature will unleash a wide range of new capabilities previously not possible, including the new ways to check possession internally!
The text was updated successfully, but these errors were encountered: