diff --git a/lib/nacl.js b/lib/nacl.js index 1f0d4d5..8bd6f4d 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.defaultRole || 'guest'; if (options.rules) { opt.rules = utils.validate(options.rules); @@ -70,9 +70,19 @@ 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; + /** + * 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