Create Roles and Permissions Dynamically
Yes, it is possible to set ACL dynamically using NbAclService using setAccessControl() method (https://akveo.github.io/nebular/docs/security/nbaclservice). It accepts the same data format as accessContorol property of the forRoot method.
So you can inject it somewhere for example in your app.component, request ACL from some API and set it using that setAccessControl() method.
Thanks for the feedback Dmitry Nehaychik will try to implement it.
Hi @nnixaa ,
I have to try to interface from laravel backend api to angular.
The acl system composed of user->role->permission. How should be the list to pass at method setAccessControl?
Here you go https://akveo.github.io/nebular/docs/security/acl-configuration--usage#acl-configuration
{
guest: {
view: ['news', 'comments'],
},
user: {
parent: 'guest',
create: 'comments',
},
moderator: {
parent: 'user',
create: 'news',
remove: '*',
},
},
Thank for your reply.
In my backend management i've no resourse join to permission/role. If i map my list as below?
{
role1 :{
view-menu:'*',
insert-new-doc:'*',
},
role2: {
delete-doc:'*',
modify:'*'
}
}
Then for each element/button etc verify the permission with directive
isGranted="['view-menu','insert-new-doc']".
Will it work?
yes, it will, the only thing in your case is that the isGranted would go like this:
isGranted="['view-menu','*']"
Thank a lot. I had gone out crazy. I try it.
Could someone please give an example of how dynamic permissions are achieved