diff --git a/lib/acl.js b/lib/acl.js index ff52c00..f6c5565 100644 --- a/lib/acl.js +++ b/lib/acl.js @@ -39,10 +39,11 @@ internals.isGranted = function(userRole, requiredRole, hierarchy) { // If the user's role is not any of the possible roles if (index === -1) { - return false; - } - - userRoles = _.rest(hierarchy, index); // Get all the possible roles in the hierarchy + userRoles = userRole; + }else{ + userRoles = _.rest(hierarchy, index); // Get all the possible roles in the hierarchy + } + } else { userRoles = userRole; } diff --git a/lib/index.js b/lib/index.js index f21012b..14bf081 100644 --- a/lib/index.js +++ b/lib/index.js @@ -101,7 +101,9 @@ internals.validateRoutes = (server) => { * @param h Hapi Reponse Toolkit https://hapijs.com/api#response-toolkit */ internals.onPreHandler = async (request, h) => { - + //#28 server.binds send to h.context now + const config = h.context.config; + // Ignore OPTIONS requests if (request.route.method === 'options') { return h.continue; @@ -128,9 +130,9 @@ internals.onPreHandler = async (request, h) => { let roleHierarchy = null; // If we're not using hierarchy - if (!!this.config && this.config.hierarchy === true) { + if (!!config && config.hierarchy === true) { // this.config comes from plugin.bind - roleHierarchy = this.config.roleHierarchy; + roleHierarchy = config.roleHierarchy; } else { roleHierarchy = false; }