简体   繁体   中英

How to remove role of a user from particular resource in node_acl?

I have multiple resource and multiple user in my project. Single user may have different-2 role on different-2 resource. But the problem with node_acl is, if I want to remove the role of a user from a particular resource there is no any feature(way).

let me explain this.

I have 2 resource let call then "resource A" and "resource B" and on both resource User "Bharat" have admin role.

Allow resource

redisAcl.allow([{
    roles: ['admin'],
    allows: [{
        resources: "resources A",
        permissions: "Put"
    }]
},{
    roles: ['admin'],
    allows: [{
        resources: "resources B",
        permissions: "get"
    }]
}]);

Adding user role

redisAcl.addUserRoles("Bharat", "Admin", function() { 

})

It will set Admin role to "Bharat: on both resource. Ok I will manage this for time being. Because I have a built in method to check permission on any resource.

Like

  redisAcl.isAllowed("Bharat", "resources A", "get", function(err, allowed) { 
console.log("first",allowed); // result is false})

     redisAcl.isAllowed("Bharat", "resources B", "get", function(err, allowed) {
console.log("first",allowed); // result is true. })

But if i want to revoke the admin role from "Bharat" . If I use removeUserRoles() method for reworking the admin role from "resource B" .

redisAcl.removeUserRoles("Bharat", "admin", function() {

    })

it will also revoke the admin role of "Bharat" from "resource A" . is there any way to do this or remove("revoke") role of a user from particular resource with node_acl.

I am using node_acl module to managing ACL.

A somewhat similar issues raised on the Node ACL site around how individual roles are removed.

https://github.com/OptimalBits/node_acl/issues/160

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM