Aggiornamenti

This commit is contained in:
Paolo Arena
2020-04-24 10:29:25 +02:00
parent 4a9fa9cf61
commit 2549d43447
21 changed files with 733 additions and 390 deletions

View File

@@ -7,14 +7,20 @@ const tools = require('../tools/general');
var { authenticate } = require('../middleware/authenticate');
router.post('/updateval', authenticate, (req, res) => {
router.post('/updateval', authenticate, async (req, res) => {
console.log('/updateval', req.body.pairval);
idapp = req.body.idapp;
pair = req.body.pairval;
cfgserver.findOneAndUpdate({chiave: pair.chiave, userID: pair.userId}, { $set: pair }, { new: false }).then((item) => {
// cfgserver.find({ chiave: pair.chiave }, (err, item) => {
res.status(200).send();
}).catch(err => {
return await cfgserver.findOneAndUpdate({ chiave: pair.chiave, idapp, userId: pair.userId }, { $set: pair }, { new: false })
.then((item) => {
// cfgserver.find({ chiave: pair.chiave }, (err, item) => {
if (!!item) {
res.status(200).send();
} else {
res.status(400).send();
}
}).catch(err => {
console.log('ERR:', err);
res.status(400).send();
})