- fix: return the item saved

This commit is contained in:
Paolo Arena
2019-02-08 17:11:33 +01:00
parent 87378fe732
commit 318ff7a798
7 changed files with 35 additions and 17 deletions

View File

@@ -5,18 +5,19 @@ const tools = require('../tools/general');
var authenticate = (req, res, next) => {
var token = req.header('x-auth');
// console.log("TOKEN = " + token);
tools.mylogshow("TOKEN = " + token);
User.findByToken(token).then((user) => {
// tools.mylogshow('userid', user._id)
if (!user) {
return Promise.reject();
}
tools.mylogshow('userid', user._id)
req.user = user;
req.token = token;
next();
}).catch((e) => {
tools.mylogshow("ERR = " + e);
res.status(401).send();
});
};