Remove legacy hack
This commit is contained in:
parent
ff19a8a2fe
commit
85d4c81e58
@ -27,11 +27,12 @@ var REQUEST_QUERY_PARAMS_WHITELIST = [
|
|||||||
module.exports = function prepareContextMiddleware (authApi, pgConnection) {
|
module.exports = function prepareContextMiddleware (authApi, pgConnection) {
|
||||||
return function prepareContext (req, res, next) {
|
return function prepareContext (req, res, next) {
|
||||||
var allowedQueryParams = REQUEST_QUERY_PARAMS_WHITELIST;
|
var allowedQueryParams = REQUEST_QUERY_PARAMS_WHITELIST;
|
||||||
|
|
||||||
if (Array.isArray(req.context.allowedQueryParams)) {
|
if (Array.isArray(req.context.allowedQueryParams)) {
|
||||||
allowedQueryParams = allowedQueryParams.concat(req.context.allowedQueryParams);
|
allowedQueryParams = allowedQueryParams.concat(req.context.allowedQueryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
req.query = _.pick(req.query, allowedQueryParams);
|
req.query = _.pick(req.query, allowedQueryParams);
|
||||||
req.params = _.extend({}, req.params); // shuffle things as request is a strange array/object
|
|
||||||
|
|
||||||
var user = req.context.user;
|
var user = req.context.user;
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ describe('prepare-context', function() {
|
|||||||
done: function() {}
|
done: function() {}
|
||||||
};
|
};
|
||||||
req.context = { user: 'localhost' };
|
req.context = { user: 'localhost' };
|
||||||
|
req.params = {};
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user