Casl: Extends "manage" with another rule

Created on 3 Aug 2018  路  4Comments  路  Source: stalniy/casl

How can I extend manage ability to include another rule?
Anything like this:
Ability.addAlias("manage", ["list"]);
or
Ability.addAlias("manage", ["list", "manage"]);

question

All 4 comments

You can create custom alias with name access:

Ability.addAlias("access", ["list", "manage"])

Another approach is to extend what is inside manage (read, create, update, delete)

Ability.addAlias('read', ['list'])

// later when you define rules
const abiltiy = AbilityBuilder.define(can => {
  can('read', 'Product')
})

ability.can('list', 'Product') // true
ability.can('read', 'Product') // true

Thank you sir! I'm implementing the first option right now

Thanks for using CASL! I'm closing this as there are no action items anymore

Was this page helpful?
0 / 5 - 0 ratings