Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Roles functionality

See original GitHub issue

I’m submitting a…

[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[x ] Feature request
[ ] Documentation issue or request

Current behavior

Although roles can be defined using addRoles, assigning a name and a list of permissions, there appears to be no functionality gained by doing so, that I can see. The permission list is ignored and only the role names are relevant. Perhaps I’m misunderstanding.

Expected behavior

I would expect the ability to assign one or more of the defined roles to the current session and that the relevant permissions would be included in authorization checks such as ngxPermissionsOnly.

Minimal reproduction of the problem with instructions

// Define a role in typescript
this.roleService.addRole('ANALYST', [

// Use the assigned permission from the list in a directive in html
<div *ngxPermissionsOnly="['accessAnalystsSection']">
<p>I have Analyst permission.</p>

// The above will never be displayed because the permission list defined above is ignored, only the role name is checked in the NgxRolesService.hasRolePermission method


Angular version: 6.1.6
ngx-permissions version: 6.0.1

- [x ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:18
  • Comments:30 (10 by maintainers)

github_iconTop GitHub Comments

troydietzcommented, Nov 20, 2019

@AlexKhymenko Thank you for your response. I think I understand where the confusion is coming from. The way I think I’d use a role is a different from you. In most cases, I would never think of using a role in the ngxPermission directive. Instead, I’d only use permissions.

For example, this is how I imagine using roles and permissions:

<div *ngxPermissions="canViewMessage">
  <div *ngFor="message in messages">
    <span>{{ message }}</span>
    <a *ngxPermissions="canDeleteMessage" (click)="deleteMessage(message)">Delete</a>
  <compose-message *ngxPermissions="canPostMessage"></compose-message>

Possible roles: role: Anonymous, permissions: [canViewMessage] role: User, permissions: [canViewMessage, canPostMessage] role: Admin, permissions: [canViewMessage, canPostMessage, canDeleteMessage]

I can’t think of a time where I’d really want to say *ngxPermissions=“Admin”. And since with ngx-permission you have to load all of the permissions before creating the Admin role, creating the role doesn’t provide me anymore benefit. To be clear, I’m not saying your approach is wrong, I’m just starting to understand why I was confused before. I think you and I think of using roles in slightly different ways.

Thank you very much for your response 😃

AlexKhymenkocommented, Sep 23, 2020

Thank For all Your patience. Added this functionality + more. Added addRoleWithPermissions, addRolesWithPermissions, flushRolesAndPermissions. Available in 8.1.1. Have a great day 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Are Functional Roles in the Workplace?
Employees are typically hired to work in one of four functional areas of business which usually include marketing, operations, human resources and finance....
Read more >
What Is The “Roles” Functionality? - SiteGround KB
The Role defines the set of tools that your clients will see in their white-label Site Tools. These should be the tools you...
Read more >
Functional roles - Creatio Academy
Functional roles reflect employee job titles, e.g., “Sales Managers”. To manage functional roles, click → Functional roles. The Functional roles section ...
Read more >
Understanding Functional and Access Roles
A functional role is a class of user that controls access to systems when performing work in PMF. An access role is created...
Read more >
Roles and Capabilities – Forums
A Role defines a set of tasks a user assigned the role is allowed to perform. For instance, the Super Admin role encompasses...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found