Ngx-admin: Create Roles and Permissions Dynamically

Created on 11 Jul 2018  路  8Comments  路  Source: akveo/ngx-admin

Request type

Create Roles and Permissions Dynamically

  • [ ] bug report
  • [ ] feature request
  • [x] question about the decisions made in the repository

Request description

  • Is it possible to create new roles (guest, user, moderator) and permissions (view, create, remove) using the default Nebular Security AC
faq question

All 8 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Kalaijagdai picture Kalaijagdai  路  4Comments

lopn picture lopn  路  4Comments

fabltd picture fabltd  路  3Comments

AZm1n picture AZm1n  路  4Comments

argnist picture argnist  路  4Comments