- fix: authenticate_withUser mancava su alcuni...
- fix: '/signin' non riproponeva il login nel caso il token fosse invalido
This commit is contained in:
@@ -78,6 +78,7 @@ module.exports = {
|
|||||||
console.log(' ... Non inserito !');
|
console.log(' ... Non inserito !');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Il documento esiste, lo aggiorniamo
|
// Il documento esiste, lo aggiorniamo
|
||||||
const ris = await table.updateOne({ _id: existingDoc._id }, { $set: rec });
|
const ris = await table.updateOne({ _id: existingDoc._id }, { $set: rec });
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const router = express.Router();
|
|||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
const server_constants = require('../tools/server_constants');
|
const server_constants = require('../tools/server_constants');
|
||||||
|
|
||||||
const { authenticate } = require('../middleware/authenticate');
|
const { authenticate, authenticate_withUser } = require('../middleware/authenticate');
|
||||||
|
|
||||||
const { Booking } = require('../models/booking');
|
const { Booking } = require('../models/booking');
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ const sendNotifBooking = async (res, idapp, user, recbooking) => {
|
|||||||
return await sendemail.sendEmail_CancelBooking(res, user.lang, user.email, user, idapp, recbooking);
|
return await sendemail.sendEmail_CancelBooking(res, user.lang, user.email, user, idapp, recbooking);
|
||||||
};
|
};
|
||||||
|
|
||||||
router.post('/', authenticate, (req, res) => {
|
router.post('/', authenticate_withUser, (req, res) => {
|
||||||
// tools.mylog('INIZIO - booking');
|
// tools.mylog('INIZIO - booking');
|
||||||
// tools.mylog('req.body', req.body);
|
// tools.mylog('req.body', req.body);
|
||||||
const myrec = _.pick(req.body, tools.allfieldBooking());
|
const myrec = _.pick(req.body, tools.allfieldBooking());
|
||||||
|
|||||||
@@ -1813,11 +1813,11 @@ async function testMongoPerformance(ind, iterations = 20) {
|
|||||||
if (ind === 1) {
|
if (ind === 1) {
|
||||||
await User.findOne({}).lean();
|
await User.findOne({}).lean();
|
||||||
} else {
|
} else {
|
||||||
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiJQUk9WQU1TR0AxQSIsInNtYXJ0IjoiNjIwODAwYWRjMTI5ZDFlYmE3NjBiZWNiIiwiYWNjZXNzIjoiYXV0aCIsInVuIjoic3VyeWExOTc3IiwiaWF0IjoxNzQxODcyMzEwLCJleHAiOjE3NDE4Nzk1MTB9.SXJLmsS6EZVhaU7sUWYMnaqGpiiy8RfE9K43xTdxNuU';
|
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiJQUk9WQU1TR0AxQSIsInNtYXJ0IjoiNjIwODAwYWRjMTI5ZDFlYmE3NjBiZWNiIiwiYWNjZXNzIjoiYXV0aCIsInVuIjoic3VyeWExOTc3IiwiaWF0IjoxNzQxODcyMzEwLCJleHAiOjE3NDE4Nzk1MTB9.SXJLmsS6EZVhaU7sUWYMnaqGpiiy8RfE9K43xTdxNuU';
|
||||||
|
|
||||||
await User.findByToken(token, 'auth', true, true);
|
await User.findByToken(token, 'auth', true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log(`Errore nell'iterazione ${i + 1}: ${err.message}`);
|
log(`Errore nell'iterazione ${i + 1}: ${err.message}`);
|
||||||
}
|
}
|
||||||
@@ -1917,9 +1917,14 @@ async function load(req, res, version = '0') {
|
|||||||
// Estrazione e validazione degli input
|
// Estrazione e validazione degli input
|
||||||
const userId = req.user ? req.user._id.toString() : req.params.userId || '0';
|
const userId = req.user ? req.user._id.toString() : req.params.userId || '0';
|
||||||
const idapp = req.params.idapp;
|
const idapp = req.params.idapp;
|
||||||
const status = req.code === server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED
|
/*const status = req.code === server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED
|
||||||
? server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED
|
? server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED
|
||||||
: 200;
|
: 200;*/
|
||||||
|
|
||||||
|
let status = req.code;
|
||||||
|
if (status === server_constants.RIS_CODE_OK) {
|
||||||
|
status = 200;
|
||||||
|
}
|
||||||
|
|
||||||
// Determina se l'utente ha determinati permessi
|
// Determina se l'utente ha determinati permessi
|
||||||
const gestoredelSito = req.user &&
|
const gestoredelSito = req.user &&
|
||||||
@@ -2118,7 +2123,8 @@ async function load(req, res, version = '0') {
|
|||||||
catalogs: data.catalogs,
|
catalogs: data.catalogs,
|
||||||
catprtotali: data.catprtotali
|
catprtotali: data.catprtotali
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// console.log(' ... 2) load dati caricati ...');
|
// console.log(' ... 2) load dati caricati ...');
|
||||||
res.status(status).send(responseData);
|
res.status(status).send(responseData);
|
||||||
|
|||||||
@@ -861,7 +861,7 @@ router.post('/groups', authenticate, (req, res) => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/circuits', authenticate, (req, res) => {
|
router.post('/circuits', authenticate_withUser, (req, res) => {
|
||||||
const username = req.user.username;
|
const username = req.user.username;
|
||||||
idapp = req.body.idapp;
|
idapp = req.body.idapp;
|
||||||
locale = req.body.locale;
|
locale = req.body.locale;
|
||||||
@@ -1800,7 +1800,7 @@ router.post('/infomap', authenticate, async (req, res) => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/mgt', authenticate, async (req, res) => {
|
router.post('/mgt', authenticate_withUser, async (req, res) => {
|
||||||
|
|
||||||
const mydata = req.body.mydata;
|
const mydata = req.body.mydata;
|
||||||
idapp = req.body.idapp;
|
idapp = req.body.idapp;
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.2.19
|
1.2.21
|
||||||
Reference in New Issue
Block a user