Gestione Refresh Token Completata !

This commit is contained in:
Surya Paolo
2024-04-11 11:43:19 +02:00
parent 07c210c59e
commit c2d76ff10a
12 changed files with 51 additions and 29 deletions

View File

@@ -260,7 +260,7 @@ router.post(process.env.LINK_UPDATE_PWD, async (req, res) => {
// Salva lo User
user.save().then(() => {
res.header('x-auth', ris.token)
.header('x-refrTok', ris.refreshToken)
.header('x-refrtok', ris.refreshToken)
.send({ code: server_constants.RIS_CODE_OK }); // Ritorna il token di ritorno
});
});
@@ -1384,12 +1384,12 @@ router.get('/loadsite/:userId/:idapp', authenticate_noerror, (req, res) => {
});
router.get('/loadsite/:userId/:idapp/:vers', authenticate_noerror,
(req, res) => {
async (req, res) => {
let versionstr = req.params.vers;
let version = tools.getVersionint(versionstr);
load(req, res, version);
return await load(req, res, version);
});
@@ -1397,6 +1397,12 @@ function load(req, res, version) {
const userId = req.params.userId;
const idapp = req.params.idapp;
let status = 200
if (req.code === server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED) {
status = server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED
}
if (!version) {
version = '0';
}
@@ -1585,7 +1591,7 @@ function load(req, res, version) {
} catch (e) { }
}
if (version < 91) {
res.send({
res.status(status).send({
bookedevent: arrdata[0],
eventlist: arrdata[1],
operators: arrdata[2],
@@ -1612,7 +1618,7 @@ function load(req, res, version) {
internalpages: arrdata[23],
});
} else {
res.send({
res.status(status).send({
bookedevent: arrdata[0],
eventlist: arrdata[1],
operators: arrdata[2],
@@ -1663,6 +1669,7 @@ function load(req, res, version) {
subcatprods: arrdata[46],
catprods_gas: arrdata[47],
catAI: arrdata[48],
code: req.code,
});
const prova = 1;
@@ -1680,7 +1687,7 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate_noerror, async (req, res
// console.log("POST " + process.env.LINK_CHECK_UPDATES + " userId=" + userId);
if (!req.user) {
return res.status(404).send();
return res.status(200).send();
}
await CfgServer.find({ idapp }).then((arrcfgrec) => {
@@ -1702,7 +1709,7 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate_noerror, async (req, res
if (!ObjectID.isValid(userId)) {
return res.status(404).send();
}
last_msgs = SendMsg.findLastGroupByUserIdAndIdApp(userId, req.user.username, idapp);
last_notifs = SendNotif.findLastNotifsByUserIdAndIdApp(req.user.username, idapp, 40);