- fix: sistemato pagina gruppo che non si visualizzava (errore per modifica)
- fix: corretto il "Invia RIS" al gruppo.
This commit is contained in:
@@ -753,9 +753,11 @@ UserSchema.statics.findByToken = async function (token, typeaccess, con_auth, wi
|
||||
let user = null;
|
||||
let decoded;
|
||||
const start = process.hrtime.bigint();
|
||||
const start_jwt = process.hrtime.bigint();
|
||||
|
||||
if (!token) return { user, code };
|
||||
|
||||
|
||||
try {
|
||||
decoded = jwt.verify(token, process.env.SIGNCODE);
|
||||
code = server_constants.RIS_CODE_OK;
|
||||
@@ -769,9 +771,13 @@ UserSchema.statics.findByToken = async function (token, typeaccess, con_auth, wi
|
||||
return { user: null, code };
|
||||
}
|
||||
|
||||
const end_jwt = process.hrtime.bigint();
|
||||
// console.log(` jwt.verify impiega ${Math.round(Number(end_jwt - start_jwt) / 1e6) / 1000} secondi.`);
|
||||
|
||||
let project = undefined;
|
||||
|
||||
if (withuser) {
|
||||
const start_find = process.hrtime.bigint();
|
||||
if (withlean) {
|
||||
user = await User.findOne({
|
||||
_id: decoded.smart,
|
||||
@@ -793,10 +799,13 @@ UserSchema.statics.findByToken = async function (token, typeaccess, con_auth, wi
|
||||
},
|
||||
}, project);
|
||||
}
|
||||
const end_find = process.hrtime.bigint();
|
||||
console.log(` User.findOne impiega ${Math.round(Number(end_find - start_find) / 1e6) / 1000} secondi.`);
|
||||
} else {
|
||||
|
||||
project = { perm: 1, _id: 1, idapp: 1, username: 1, deleted: 1, aportador_solidario: 1, aportador_solidario_nome_completo: 1, 'profile.socioresidente': 1 };
|
||||
|
||||
const start_find = process.hrtime.bigint();
|
||||
user = await User.findOne({
|
||||
_id: decoded.smart,
|
||||
tokens: {
|
||||
@@ -806,6 +815,8 @@ UserSchema.statics.findByToken = async function (token, typeaccess, con_auth, wi
|
||||
},
|
||||
},
|
||||
}, project).lean();
|
||||
const end_find = process.hrtime.bigint();
|
||||
// console.log(` User.findOne LEAN impiega ${Math.round(Number(end_find - start_find) / 1e6) / 1000} secondi.`);
|
||||
}
|
||||
|
||||
if (user) {
|
||||
@@ -817,8 +828,8 @@ UserSchema.statics.findByToken = async function (token, typeaccess, con_auth, wi
|
||||
}
|
||||
}
|
||||
|
||||
const end = process.hrtime.bigint();
|
||||
console.log(` findByToken impiega ${Math.round(Number(end - start) / 1e6) / 1000} secondi.`);
|
||||
// const end = process.hrtime.bigint();
|
||||
// console.log(` findByToken impiega ${Math.round(Number(end - start) / 1e6) / 1000} secondi.`);
|
||||
|
||||
return { user, code };
|
||||
};
|
||||
@@ -6334,8 +6345,11 @@ UserSchema.statics.getMyGroupsById = async function (id) {
|
||||
|
||||
// cerca lo user by id e ritorna "profile.mygroups"
|
||||
const ris = await User.findOne({ _id: id }, { 'profile.mygroups': 1 }).lean();
|
||||
if (ris && ris.profile) {
|
||||
return ris.profile.mygroups;
|
||||
}
|
||||
|
||||
return ris;
|
||||
return [];
|
||||
};
|
||||
UserSchema.statics.createNewSubRecord = async function (idapp, req) {
|
||||
const User = this;
|
||||
@@ -6414,6 +6428,7 @@ const FuncUsers = {
|
||||
}
|
||||
};
|
||||
|
||||
UserSchema.index({ 'tokens.token': 1, 'tokens.access': 1 });
|
||||
|
||||
module.exports = {
|
||||
User, Hero, FuncUsers
|
||||
|
||||
Reference in New Issue
Block a user