README
The with an extra function to create a custom action. Everything else is the same.
New execute function
Define roles and grants one by one.
AccessControl.addAction(['move', 'login']); // Register your new actions here, note that: Create, Read, Update, Delete are added by default. This will set strict mode and you wont be able to create custom actions on fly exp: ac.grant('user').execute('myaction').on('video'); will thow an error
const ac = new AccessControl();
ac.grant('user') // define new or modify existing role. also takes an array.
.execute('move').on('video') // equivalent to .execute('move:any').on('video', ['*'])
.grant('admin') // switch to another role without breaking the chain
.extend('user') // inherit role capabilities. also takes an array
.execute('login').on('website');
const permission = ac.can('user').execute('move').on('video');
console.log(permission.granted); // —> true
console.log(permission.attributes); // —> ['*'] (all attributes)
permission = ac.can('admin').execute('login').on('website');
console.log(permission.granted); // —> true
console.log(permission.attributes); // —> ['*']