diff --git a/lib/acl.js b/lib/acl.js index a5fbd97..0cee404 100644 --- a/lib/acl.js +++ b/lib/acl.js @@ -640,10 +640,12 @@ Acl.prototype.middleware = function(numPathComponents, userId, actions){ if (err){ next(new Error('Error checking permissions to access resource')); }else if(allowed === false){ - acl.logger?acl.logger.debug('Not allowed '+_actions+' on '+resource+' by user '+_userId):null; - acl.allowedPermissions(_userId, resource, function(err, obj){ - acl.logger?acl.logger.debug('Allowed permissions: '+util.inspect(obj)):null; - }); + if (acl.logger) { + acl.logger.debug('Not allowed '+_actions+' on '+resource+' by user '+_userId); + acl.allowedPermissions(_userId, resource, function(err, obj){ + acl.logger.debug('Allowed permissions: '+util.inspect(obj)); + }); + } next(new HttpError(403,'Insufficient permissions to access resource')); }else{ acl.logger?acl.logger.debug('Allowed '+_actions+' on '+resource+' by user '+_userId):null;