question-mark
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.

Getting permissions by defined Role

See original GitHub issue

Is it possible to get the array of permissions from a defined role? After login I’ve only got access to the role name from the authenticated user. (developer, seo, accountant, …)


var permissions = [

    // dashboard
    "dashboard",

    // catalog
    "product-list",
    "product-edit",
    "stock-list",
    "category-list",
    "manufacturer-list",
    "manufacturer-edit",
    "producttype-list",
    "producttype-edit",
    "specification-list",
    "specification-edit",

    // sales
    "invoice-list",
    "invoice-edit",
    "order-list",
    "order-edit",
    "quote-list",
    "quote-edit",

    // customers
    "customer-list",
    "customer-edit",

    // tools
    "seo-edit",
    "sync-list",

    // warehouse
    "warehouse-location-list",
    "warehouse-stock-report"
];

PermissionStore.defineManyPermissions(permissions, function (permissionName, transitionProperties) {
     return authService.checkUserPermissions(permissionName);
});

RoleStore.defineRole("developer", function() { return true; });
RoleStore.defineRole("seo", ["dashboard", "seo-list"]);
RoleStore.defineRole("accountant", ["dashboard", "customer-list", "customer-edit"]);
function checkUserPermissions(permissionName) {

    if (auth.isAuthenticated) {

        if (common.isNotEmpty(auth.profile)) {

            var roles = _.toArray(auth.profile.roles);
            var permissions = [];

            roles.forEach(function(role) {

                // GET THE PERMISSONS FOR THIS ROLE

            });

            return _.contains(permissions, permissionName);
        }

    }

    return false;
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
Nessecommented, Dec 13, 2016

When updating to version 5.1.0 this solutions is broken. Could this be resolved? I was updating from version 4.0.4 to 5.1.0

0reactions
masterspambotcommented, Dec 23, 2016

Nothing was no changes made in this method @Nesse

Read more comments on GitHub >

github_iconTop Results From Across the Web

Role-based permissions overview - N-able
The access is the permission the user has to perform work. Roles define the job based on the requirements of the position. With...
Read more >
Defining Role Permissions - Liferay Help Center
Defining Role Permissions · Go to the Control Panel and then click on Users → Roles. · On the Regular Roles screen, click...
Read more >
What is the difference between a role and a permission?
Here are the system defined roles: Super Admin: User has all system permissions. Admin: User has all system permissions except the ability to...
Read more >
Creating and managing custom roles - IAM - Google Cloud
Use the gcloud iam list-testable-permissions command to get a list of permissions that are available for custom roles in a specific project or...
Read more >
Managing Roles and Permissions - FIWARE Tutorials
To grant an organization access to an application, click on the appliation to get to the details page and scroll to the bottom...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found