From 7bb4ca4f4521221efdff780b9facd710e0536711 Mon Sep 17 00:00:00 2001 From: FilipDusek Date: Sat, 27 May 2017 10:20:56 +0200 Subject: [PATCH 1/3] Default role issue Fixes a typo causing default role not to be applied --- lib/nacl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nacl.js b/lib/nacl.js index 1f0d4d5..7672afd 100644 --- a/lib/nacl.js +++ b/lib/nacl.js @@ -23,7 +23,7 @@ function config(config, response) { opt.response = response; opt.baseUrl = options.baseUrl; opt.decodedObjectName = options.decodedObjectName; - opt.defautRole = options.defautRole || 'guest'; + opt.defaultRole = options.defautRole || 'guest'; if (options.rules) { opt.rules = utils.validate(options.rules); @@ -70,7 +70,7 @@ function authorize(req, res, next) { * @type {[type]} */ - let role = helper.getRole(req, res, opt.decodedObjectName, opt.defautRole); + let role = helper.getRole(req, res, opt.decodedObjectName, opt.defaultRole); if (!_.isString(role) || !role) return; From a0bc0e3b607a731f6379ac7440491e8b8d8500b1 Mon Sep 17 00:00:00 2001 From: FilipDusek Date: Sun, 28 May 2017 21:51:08 +0200 Subject: [PATCH 2/3] Default role issue --- lib/nacl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nacl.js b/lib/nacl.js index 7672afd..9121d37 100644 --- a/lib/nacl.js +++ b/lib/nacl.js @@ -23,7 +23,7 @@ function config(config, response) { opt.response = response; opt.baseUrl = options.baseUrl; opt.decodedObjectName = options.decodedObjectName; - opt.defaultRole = options.defautRole || 'guest'; + opt.defaultRole = options.defaultRole || 'guest'; if (options.rules) { opt.rules = utils.validate(options.rules); From 5548ae3c4b93f3ad74269f8cd7b33bd1a3d27af8 Mon Sep 17 00:00:00 2001 From: HussainAliAkbar Date: Thu, 22 Jun 2017 21:20:49 +0500 Subject: [PATCH 3/3] Fix: Issue#79: called the utils.deny function when the validation whether the provided role is a string or not fails. --- lib/nacl.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/nacl.js b/lib/nacl.js index 9121d37..8bd6f4d 100644 --- a/lib/nacl.js +++ b/lib/nacl.js @@ -72,7 +72,17 @@ function authorize(req, res, next) { let role = helper.getRole(req, res, opt.decodedObjectName, opt.defaultRole); - if (!_.isString(role) || !role) return; + /** + * if no role or role not provided as string + */ + if (!_.isString(role) || !role) { + return utils.deny( + res, + 404, + 'REQUIRED: Role should be provided as a string', + null + ); + } /** * get resource from the url