Add a flag to control ACL DB lookup

This commit is contained in:
Raymond Feng 2015-07-27 07:52:50 -07:00
parent caa81676b7
commit 9e5c46a2b8
1 changed files with 22 additions and 8 deletions

View File

@ -413,13 +413,9 @@ module.exports = function(ACL) {
var staticACLs = this.getStaticACLs(model.modelName, property); var staticACLs = this.getStaticACLs(model.modelName, property);
var self = this; var self = this;
function checkACLs(acls, callback) {
var roleModel = registry.getModelByType(Role); var roleModel = registry.getModelByType(Role);
this.find({where: {model: model.modelName, property: propertyQuery,
accessType: accessTypeQuery}}, function(err, acls) {
if (err) {
if (callback) callback(err);
return;
}
var inRoleTasks = []; var inRoleTasks = [];
acls = acls.concat(staticACLs); acls = acls.concat(staticACLs);
@ -464,7 +460,25 @@ module.exports = function(ACL) {
resolved.debug(); resolved.debug();
if (callback) callback(null, resolved); if (callback) callback(null, resolved);
}); });
}
var ignoreACLsFromDB = self.settings && self.settings.ignoreACLsFromDB;
if (ignoreACLsFromDB) {
return checkACLs([], callback);
} else {
self.find({
where: {
model: model.modelName, property: propertyQuery,
accessType: accessTypeQuery
}
}, function(err, acls) {
if (err) {
if (callback) callback(err);
return;
}
checkACLs(acls, callback);
}); });
}
}; };
/** /**