简体   繁体   中英

Acl node.js module

I'm trying to use acl module for user permissions.

I've installed the module with npm install acl --save .

Added these lines to code:

var acl = require('acl');
var redisClient = require('redis');

acl = new acl(new acl.redisBackend(redisClient, 'session'));

acl.allow('member', 'events', 'view');

Received this error:

TypeError: Object #<Object> has no method 'multi'
    at Object.RedisBackend.begin (workspace/server/node_modules/acl/lib/redis-backend.js:23:23)
    at Acl.allow (workspace/server/node_modules/acl/lib/acl.js:231:37)
    at Object.<anonymous> (workspace/server/app.js:24:5)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Object..js (/usr/lib/node_modules/node-dev/lib/hook.js:52:17)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)

Any ideas?

The issue was that the redisClient was not properly initialized.

//this line did the trick
var redisInstance = require('redis').createClient(6379, '127.0.0.1', {no_ready_check: true});

and then

acl = new acl(new acl.redisBackend(redisInstance, 'session'));

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