- fix: refresh token, codice di errore ...

This commit is contained in:
Surya Paolo
2025-03-15 14:52:33 +01:00
parent 7d845355a9
commit a03c4cf613
5 changed files with 9 additions and 6 deletions

View File

@@ -29,7 +29,7 @@ GCM_API_KEY=""
PROD=0
PROJECT_DESCR_MAIN='__PROJECTS'
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
TOKEN_LIFE=2h
TOKEN_LIFE=1m
REFRESH_TOKEN_LIFE=14d
FTPSERVER_HOST=139.162.166.31
FTPSERVER_PORT=21

View File

@@ -22,7 +22,7 @@ const authenticateMiddleware = async (req, res, next, withUser = false, lean = f
req.token = null;
req.code = server_constants.RIS_CODE_HTTP_INVALID_TOKEN;
console.log(` ## ${logPrefix}_TOKEN INVALIDO ❌ ...`);
return noError ? next() : res.status(server_constants.RIS_CODE_HTTP_INVALID_TOKEN).send();
return noError ? next() : res.status(req.code).send();
}
const user = await User.findByToken(token, 'auth', false, withUser, lean);
@@ -54,7 +54,7 @@ const authenticateMiddleware = async (req, res, next, withUser = false, lean = f
req.user = null;
req.token = null;
req.code = server_constants.RIS_CODE_HTTP_INVALID_TOKEN;
noError ? next() : res.status(server_constants.RIS_CODE_HTTP_INVALID_TOKEN).send();
noError ? next() : res.status(req.code).send();
}
};

View File

@@ -753,7 +753,10 @@ UserSchema.statics.findByToken = async function (token, typeaccess, con_auth, wi
const start = process.hrtime.bigint();
const start_jwt = process.hrtime.bigint();
if (!token) return { user, code };
if (!token) {
console.warn('TOKEN VUOTO ! ');
return { user, code };
}
try {

View File

@@ -714,7 +714,7 @@ router.post('/gettable', authenticate_noerror, (req, res) => {
params.table = sanitizeHtml(params.table);
if (!shared_consts.TABLES_ENABLE_GETTABLE_FOR_NOT_LOGGED.includes(params.table) && !req.user) {
return res.status(403).send({});
return res.status(req.code).send({});
}
let idapp = req.user ? req.user.idapp : sanitizeHtml(params.idapp);

View File

@@ -1 +1 @@
1.2.21
1.2.25