From 9e5c46a2b8bdcc56b0738f7fcde857ad2f4993ab Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Mon, 27 Jul 2015 07:52:50 -0700 Subject: [PATCH] Add a flag to control ACL DB lookup --- common/models/acl.js | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/common/models/acl.js b/common/models/acl.js index c033432a..c64bc786 100644 --- a/common/models/acl.js +++ b/common/models/acl.js @@ -413,13 +413,9 @@ module.exports = function(ACL) { var staticACLs = this.getStaticACLs(model.modelName, property); var self = this; - 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; - } + + function checkACLs(acls, callback) { + var roleModel = registry.getModelByType(Role); var inRoleTasks = []; acls = acls.concat(staticACLs); @@ -464,7 +460,25 @@ module.exports = function(ACL) { resolved.debug(); 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); + }); + } }; /**