From 42a14d46a5501921d7c40939b968c75d967843e4 Mon Sep 17 00:00:00 2001 From: nerv Date: Sat, 6 May 2017 09:45:13 +0300 Subject: [PATCH] #7 it is a try fix without a hack --- lib/permission_list.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/permission_list.js b/lib/permission_list.js index 7c27349..57cce0a 100644 --- a/lib/permission_list.js +++ b/lib/permission_list.js @@ -15,18 +15,16 @@ PermissionList.prototype.next = function() { var permission = this.permissions[this.position]; - // Ensure custom assertions are run async, fixes issue #7 - setTimeout(function() { - permission.query( - this.role, - this.resource, - this.action, - this.done, - this.next.bind(this) - ); - }.bind(this)); - - this.position++; + permission.query( + this.role, + this.resource, + this.action, + this.done, + function() { + this.position++; // <-- fixes issue #7 + this.next(); + }.bind(this) // ensure proper scope? + ); }; module.exports = PermissionList;