Merge pull request #779 from CartoDB/res-locals-user

Don't overwrite data in copy from req.params to res.locals
This commit is contained in:
Simon Martín 2017-11-16 11:48:16 +01:00 committed by GitHub
commit 448dcc7d82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 11 deletions

View File

@ -1,8 +1,6 @@
const _ = require('underscore');
module.exports = function localsMiddleware(req, res, next) {
_.extend(res.locals, req.params);
// save req.params in res.locals
res.locals = Object.assign(req.params || {}, res.locals);
next();
};

View File

@ -4,11 +4,5 @@ var cdbRequest = new CdbRequest();
module.exports = function userMiddleware(req, res, next) {
res.locals.user = cdbRequest.userByReq(req);
// avoid a req.params.user equals to undefined
// overwrites res.locals.user
if(!req.params.user) {
delete req.params.user;
}
next();
};