- fix: authenticate_withUser mancava su alcuni...

- fix: '/signin' non riproponeva il login nel caso il token fosse invalido
This commit is contained in:
Surya Paolo
2025-03-14 12:52:44 +01:00
parent aeb83a512b
commit 7d845355a9
5 changed files with 17 additions and 10 deletions

View File

@@ -78,6 +78,7 @@ module.exports = {
console.log(' ... Non inserito !');
}
} else {
// Il documento esiste, lo aggiorniamo
const ris = await table.updateOne({ _id: existingDoc._id }, { $set: rec });

View File

@@ -4,7 +4,7 @@ const router = express.Router();
const tools = require('../tools/general');
const server_constants = require('../tools/server_constants');
const { authenticate } = require('../middleware/authenticate');
const { authenticate, authenticate_withUser } = require('../middleware/authenticate');
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);
};
router.post('/', authenticate, (req, res) => {
router.post('/', authenticate_withUser, (req, res) => {
// tools.mylog('INIZIO - booking');
// tools.mylog('req.body', req.body);
const myrec = _.pick(req.body, tools.allfieldBooking());

View File

@@ -1917,9 +1917,14 @@ async function load(req, res, version = '0') {
// Estrazione e validazione degli input
const userId = req.user ? req.user._id.toString() : req.params.userId || '0';
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
: 200;
: 200;*/
let status = req.code;
if (status === server_constants.RIS_CODE_OK) {
status = 200;
}
// Determina se l'utente ha determinati permessi
const gestoredelSito = req.user &&
@@ -2120,6 +2125,7 @@ async function load(req, res, version = '0') {
};
}
// console.log(' ... 2) load dati caricati ...');
res.status(status).send(responseData);
} catch (e) {

View File

@@ -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;
idapp = req.body.idapp;
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;
idapp = req.body.idapp;

View File

@@ -1 +1 @@
1.2.19
1.2.21