简体   繁体   中英

what is the best way to integrate node_acl with sails

i'd like to use https://github.com/OptimalBits/node_acl module with http://sailsjs.org Framework. So I configured sails to use mongodb like this : In /config/connection.js

mongodb: {
  adapter: 'sails-mongo',
  host: 'localhost',
  port: 27017,
  user: '',
  password: '',
  database: 'acl'
}

And in /config/models.js

{
  connection: 'mongodb',
  migrate: 'safe'
}

Now I have to configure the acl module, so in /api/controllers/AclController.js i have :

var acl = require('acl');
acl = new acl(new acl.mongodbBackend(dbInstance, 'acl_'));
module.exports = {
addUserRoles : function(req, res) {
  acl.addUserRoles('joed', 'guest', function(err,data){
    return res.json({err:err, data:data});
  });
}

Now how can I get the value of dbInstance to instanciate acl?

Note : I installed acl and sails-mongo dependencies... Thank you for your help

node_acl seems to depend on the mongodb driver, which will have different methods than the Waterline ORM that sails is using.

That said, you should be able to create 2 connections to your mongo instance, one via the node_acl library and another for waterline/sails. As long as your sails models are correctly defined they should be able to live side by side. If you want you can even prefix your node_acl tables, and completely ignore them in sails.

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