OptimalBits / node_acl

Access control lists for node applications
2.62k stars 369 forks source link

allowedPermissions > this.redis.batch is not a function #261

Closed ErikJiang closed 6 years ago

ErikJiang commented 6 years ago

code:

    const redisInst = redis.getInstance();

    const aclInst = new acl(new acl.redisBackend(redisInst, 'acl_'));

    aclInst.allow([{
      roles: 'guest',
      allows: [
        {resources: '/aclFunc/get', permissions: '*'},
      ]
    },{
      roles: 'user',
      allows: [
        {resources: '/aclFunc/edit', permissions: '*'},
      ]
    }, {
      roles: 'admin',
      allows: [
        {resources: '/aclFunc/del', permissions: '*'},
      ]
    }]);

    aclInst.addRoleParents('user', 'guest');
    aclInst.addRoleParents('admin', 'user');

    aclInst.addUserRoles('user_2', 'admin');

    let guestResult = await aclInst.userRoles('user_2');

    logger.debug(`guestResult: ${JSON.stringify(guestResult)}`);

    let permissions = await aclInst.allowedPermissions('user_2', 'admin')

result error:

[2018-02-02T21:27:11.056] [7770] [DEBUG] - guestResult: ["admin"]
TypeError: this.redis.batch is not a function
    at RedisBackend.unions (/home/xxx/workspace/src/demo/node_modules/acl/lib/redis-backend.js:72:28)
    at RedisBackend.tryCatcher (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/util.js:16:23)
    at RedisBackend.ret [as unionsAsync] (eval at makeNodePromisifiedEval (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:13:39)
    at /home/xxx/workspace/src/demo/node_modules/acl/lib/acl.js:492:25
    at tryCatcher (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:502:31)
    at Promise._settlePromise (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:559:18)
    at Promise._settlePromise0 (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:604:10)
    at Promise._settlePromises (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:683:18)
    at Promise._fulfill (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:628:18)
    at Promise._resolveCallback (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:423:57)
    at Promise._settlePromiseFromHandler (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:514:17)
    at Promise._settlePromise (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:559:18)
    at Promise._settlePromise0 (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:604:10)
    at Promise._settlePromises (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:683:18)
    at Promise._fulfill (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:628:18)
    at Promise._resolveCallback (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:423:57)
    at Promise._settlePromiseFromHandler (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:514:17)
    at Promise._settlePromise (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:559:18)
    at Promise._settlePromise0 (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:604:10)
    at Promise._settlePromises (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:683:18)
    at Promise._fulfill (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:628:18)
    at Promise._resolveCallback (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:423:57)
    at Promise._settlePromiseFromHandler (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:514:17)
    at Promise._settlePromise (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:559:18)
    at Promise._settlePromise0 (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:604:10)
    at Promise._settlePromises (/home/xxx/workspace/src/demo/node_modules/bluebird/js/release/promise.js:683:18)
ashish101184 commented 5 years ago

How this has been closed?