rbac
rbac copied to clipboard
Check permission but always getting false
var rbac = new RBAC({
roles: ["superadmin", "admin", "user", "guest"],
permissions: {
user: ["create", "delete"],
password: ["change", "forgot"],
article: ["create"],
rbac: ["update"],
},
grants: {
guest: ["create_user", "forgot_password"],
user: ["change_password"],
admin: ["user", "delete_user", "update_rbac"],
superadmin: ["admin"],
},
});
await rbac.init();
let permission = await rbac.can("admin", "create", "artical")
Get permission as always false I don't know what is missing the above code.
let permission = await rbac.can("admin", "create", "artical") should be changed to let permission = await rbac.can("admin", "create", "article")
artical->article (permission variable declaration ine) and double check the configuration, it feels like you missed the setup of roles,permissions and grantss