Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing #26 #31

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/acl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 5 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down