ensure dont overwrite data in copy from req.params to res.locals
This commit is contained in:
parent
5645cd16b3
commit
c0df0d12c6
@ -1,7 +1,7 @@
|
||||
const _ = require('underscore');
|
||||
|
||||
module.exports = function localsMiddleware(req, res, next) {
|
||||
_.extend(res.locals, req.params);
|
||||
_.defaults(res.locals, req.params);
|
||||
|
||||
next();
|
||||
};
|
||||
|
@ -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();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user