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

Multiple entries in permission collection for same action/subject. #13

Open
Singha2 opened this issue Oct 2, 2014 · 0 comments
Open

Comments

@Singha2
Copy link

Singha2 commented Oct 2, 2014

My code is as below

var mongoose = require('mongoose')
, rbac = require('./lib/');

var db = mongoose.connect('mongodb://localhost/ecommerece_rbac');

if(db)
{
console.log("connected");

var UserSchema = mongoose.Schema({

username: {type:String},
status: {type:String, default:"A"},
createdAt : {type:Date, default:Date.now}

});

UserSchema.plugin(rbac.plugin);

var User = mongoose.model('User', UserSchema);

rbac.init({
ops: [
['create', 'CallRecord'],
['read', 'CallRecord'],
['update', 'CallRecord'],
['delete', 'CallRecord']
],
callcenteragent: [

  ['read', 'CallRecord'],
  ['create', 'CallRecord']

]

}, function (err, ops, callcenteragent) {

var user1 = new User({ username: 'prince' });
user1.save();

 user1.addRole('ops', function () {
    console.log(require('util').inspect(user1.roles[0]));
 });

}

)

}

This is creating 2 document in permission collection for read and create permission in mongo.

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

1 participant