Minimalistic ACL implementation for privileges management in JS
$ npm i acler --save
or
$ yarn add acler
// using ES modules
import { check } from 'acler'
// using CommonJS modules
const { check } = require('acler')
const user = {
get roles () {
return ['moderator']
}
}
const can = check('administrator || moderator', role => {
return user.roles.includes(role)
})
if (!can) {
throw new Error('You not allowed to this resource.')
}
and (&&)
- administrator && moderator
or (||)
- administrator || moderator
not (!)
- administrator && !moderator
Having trouble? Open an issue!
The MIT License (MIT). Please see License File for more information.