diff --git a/lib/collections/acl_collection.js b/lib/collections/acl_collection.js index 45f7072..f1cca5b 100644 --- a/lib/collections/acl_collection.js +++ b/lib/collections/acl_collection.js @@ -9,6 +9,7 @@ var _debug = require('debug'); var logId = 'serverbone:collections:acl'; var acl = require('../acl'); var errors = require('../errors'); +var util = require('util'); var debug = { trace: _debug(logId + ':trace'), log: _debug(logId + ':log'), @@ -81,7 +82,12 @@ var ACLCollection = BaseCollection.extend({ var canAccess = this.canAccess(options.action, options.actor); if (!canAccess) { debug.log('no access:' + options.action + ', ' + this.type + ', ' + this.indexKey); - var error = new errors.ForbiddenError('No access to ' + options.action); + var errorMsg = util.format( + 'No access to %s (%s)', + options.action, + this.name || this.indexKey + ); + var error = new errors.ForbiddenError(errorMsg); return error; } } diff --git a/lib/collections/acl_index_mixin.js b/lib/collections/acl_index_mixin.js index 6df0cc9..e85f0d0 100644 --- a/lib/collections/acl_index_mixin.js +++ b/lib/collections/acl_index_mixin.js @@ -2,6 +2,7 @@ var _ = require('lodash'); var ACLCollection = require('./acl_collection'); var IndexMixin = require('./index_mixin'); var _debug = require('debug'); +var util = require('util'); var logId = 'serverbone:collections:acl_index_mixin'; var acl = require('../acl'); var errors = require('../errors'); @@ -60,7 +61,13 @@ var ACLIndexMixin = _.extend({}, IndexMixin, { var canAccess = this.canAccess(options.action, options.actor, model); if (!canAccess) { debug.log('no access:' + options.action + ', ' + this.type + ', ' + this.indexKey); - var error = new errors.ForbiddenError('No access to ' + options.action); + var errorMsg = util.format( + 'No access to %s (%s)', + options.action, + this.name || this.indexKey + ); + var error = new errors.ForbiddenError(errorMsg); + return error; } } diff --git a/lib/models/acl_model.js b/lib/models/acl_model.js index 7a5652f..a8b7e47 100644 --- a/lib/models/acl_model.js +++ b/lib/models/acl_model.js @@ -187,7 +187,6 @@ var ACLModel = BaseModel.extend({ if (canAccess && changedAttrs) { var schemaProps = Object.keys(this.schema.properties); changedProps = Object.keys(changedAttrs); - changedProps = _.filter(changedProps, function(prop) { return schemaProps.indexOf(prop) > -1 && this.get(prop) !== attrs[prop]; }, this); @@ -197,7 +196,7 @@ var ACLModel = BaseModel.extend({ if ((!canAccess && changedAttrs) || (noAccessTo && noAccessTo.length > 0) ) { debug.log('Failing validation, no access with action %s to %s', action, JSON.stringify(noAccessTo)); var errorMsg = util.format('No access to %s %s (%s)', action, this.type, this.id); - if (noAccessTo) errorMsg+= ' fields:' + noAccessTo; + if (noAccessTo) errorMsg += ' fields:' + noAccessTo; var error = new errors.ForbiddenError(errorMsg); if (options && options.error) { if (options.error.length === 3) {