Skip to content

Commit

Permalink
Merge pull request #304 from DavidZey/master
Browse files Browse the repository at this point in the history
allowing (custom) authorization to occur even when user login is not logged in
  • Loading branch information
etduroch committed May 25, 2016
2 parents a00ff5e + 576c28c commit 041b0c5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
48 changes: 24 additions & 24 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,31 +150,31 @@ var getRouter = exports.getRouter = function(options, cb) {
return unauthorized(res);
}
}

//authentication passed, now allow app to authorize the request
if (authRule.authorizeRequired) {
req.authRule = authRule;
return options.authorize(req, res,
completeRequest,

//the error/unauthorized case...
function(err) {
logger.warn({category: 'auth', message: 'unauthorized access attempt; url: ' + req.url + '; app auth error message: ' + (err || 'no_error_message_provided')});

if (authRule.redirectUrlUnauthorized) {
//send the user back to redirectUrlUnauthorized
req.url = authRule.redirectUrlUnauthorized;
delete req.isFeatherPage;
return next();
}

//no app configured redirect URL, just return a 403
return forbidden(res);
}

//authentication passed, now allow app to authorize the request
if (authRule.authorizeRequired) {
req.authRule = authRule;
return options.authorize(req, res,
completeRequest,

//the error/unauthorized case...
function(err) {
logger.warn({category: 'auth', message: 'unauthorized access attempt; url: ' + req.url + '; app auth error message: ' + (err || 'no_error_message_provided')});

if (authRule.redirectUrlUnauthorized) {
//send the user back to redirectUrlUnauthorized
req.url = authRule.redirectUrlUnauthorized;
delete req.isFeatherPage;
return next();
}
);
} else {
return completeRequest();
}

//no app configured redirect URL, just return a 403
return forbidden(res);
}
);
} else {
return completeRequest();
}
}
}
Expand Down
1 change: 0 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,3 @@ Date.fromArray = function(array) {
}
return null;
};

0 comments on commit 041b0c5

Please sign in to comment.