Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-acl

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-acl - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

15

lib/object.js

@@ -29,2 +29,15 @@ module.exports = function(schema, options) {

schema.methods.revokeAccess = function(key, perms) {
if (perms && this[options.path][key]) {
this[options.path][key] = this[options.path][key].filter(function(perm) {
return perms.indexOf(perm) === -1;
});
} else if (key) {
delete this[options.path][key];
} else {
this[options.path] = {};
}
this.markModified(options.path);
};
schema.methods.keysWithAccess = function(perms) {

@@ -83,2 +96,2 @@ perms || (perms = []);

};
};
};

2

package.json
{
"name": "mongoose-acl",
"description": "Mongoose ACL",
"version": "0.2.2",
"version": "0.2.3",
"author": "Scott Nelson <scott@scttnlsn.com>",

@@ -6,0 +6,0 @@ "contributors": [

@@ -109,2 +109,30 @@ var assert = require('assert');

});
describe('when revoking permissions', function() {
beforeEach(function() {
model.setAccess('foo', ['a', 'b']);
model.setAccess('bar', ['a']);
});
it('revokes all permissions in acl', function() {
model.revokeAccess();
assert.deepEqual(model._acl, {});
assert.ok(model.isModified('_acl'));
});
it('revokes permissions for key in acl', function() {
model.revokeAccess('foo');
assert.ok(!model._acl.foo);
assert.deepEqual(model.getAccess('bar'), ['a']);
assert.ok(model.isModified('_acl'));
});
it('revokes specific permission in acl', function() {
model.revokeAccess('foo', 'a');
assert.deepEqual(model.getAccess('foo'), ['b']);
assert.deepEqual(model.getAccess('bar'), ['a']);
assert.ok(model.isModified('_acl'));
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc