Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with getting startet #103

Open
Meistercoach83 opened this issue Feb 20, 2015 · 3 comments
Open

Problem with getting startet #103

Meistercoach83 opened this issue Feb 20, 2015 · 3 comments

Comments

@Meistercoach83
Copy link

hello!
i´d like to add acls to my current app.
When I try to get the acl.middleware() in a route an error occurs: ^

acl = require('acl');
module.exports = function(app) {
app.route('/articles/:articleId')
 .delete(users.requiresLogin, acl.middleware(), articles.delete);
                                              ^
TypeError: Object function (backend, logger, options){
  contract(arguments)
    .params('object')
    .params('object','object')
    .params('object','object', 'object')
    .end();

  options = _.extend({
    buckets: {
      meta: 'meta',
      parents: 'parents',
      permissions: 'permissions',
      resources: 'resources',
      roles: 'roles',
      users: 'users'
    }
  }, options);

  this.logger = logger;
  this.backend = backend;
  this.options = options;

  // Promisify async methods
  backend.endAsync = bluebird.promisify(backend.end);
  backend.getAsync = bluebird.promisify(backend.get);
  backend.cleanAsync = bluebird.promisify(backend.clean);
  backend.unionAsync = bluebird.promisify(backend.union);
} has no method 'middleware'

mongoose.connection.on("connected", function () {
    acl = new acl(new acl.mongodbBackend(mongoose.connection.db, ''));

acl.allow('Administrators', ['articles', 'users', 'bets'], '*');
// User
acl.allow('user', 'articles', ['view']);
});

How can I get it running? Is it possible to get a list with all users and their roles? And a list with roles and given relations?

@thanthos
Copy link

I investigate this a bit. I did something similar. The command will not work till the mongodb established the connection. If you use the memorybackend, the same set of code will work. Still investigating a way to get around that.

@Meistercoach83
Copy link
Author

Thanks for your help. I´ll do some other work in the meantime

@thanthos
Copy link

I might have work around this issue.
Using the below, I initialize it within app.js in express. Then I require the acl where it is used.

I do not think this is a fool proof way, as it has a time component. If it takes longer than usual to establish the ACL backend, if someone hit the application before that is completed, an error will be thrown. So not solve yet. But usable for the moment. I need advise on this whoever can give.

//initACLs.js
var mongoose = require('mongoose');
var acl = require('acl');
//Piggy back on top of our connection to the DB by Mongoose.
acl = new acl(new acl.mongodbBackend(mongoose.connection.db, 'acl_'));
module.exports = acl;
//Where I need to perform the check - I used this in my default route
var acl = require('../libs/initACLs')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants