- Corretto campo "Comune di Residenza".
- Aggiornato Completamento Profilo: Comune di Residenza. - Registrazione
This commit is contained in:
@@ -511,6 +511,16 @@ const UserSchema = new mongoose.Schema({
|
||||
resid_prov_id: {
|
||||
type: Number,
|
||||
},
|
||||
resid_comune: {
|
||||
type: String,
|
||||
trim: true,
|
||||
default: '',
|
||||
},
|
||||
resid_str_comune: {
|
||||
type: String,
|
||||
trim: true,
|
||||
default: '',
|
||||
},
|
||||
resid_province: {
|
||||
type: String,
|
||||
trim: true,
|
||||
@@ -922,12 +932,13 @@ UserSchema.statics.findByToken = async function (
|
||||
decoded,
|
||||
token,
|
||||
typeaccess,
|
||||
browser_random,
|
||||
browser_random,
|
||||
withuser,
|
||||
withlean,
|
||||
project
|
||||
);
|
||||
|
||||
|
||||
// Verifica scadenza token per idapp specifici
|
||||
if (user) {
|
||||
const checkExpiry = tools.getEnableTokenExpiredByIdApp(user.idapp);
|
||||
@@ -937,6 +948,8 @@ UserSchema.statics.findByToken = async function (
|
||||
console.log('🔴 Il token è scaduto, generazione del nuovo token...');
|
||||
code = server_constants.RIS_CODE_HTTP_TOKEN_EXPIRED;
|
||||
}
|
||||
} else {
|
||||
code = server_constants.RIS_CODE_HTTP_INVALID_TOKEN;
|
||||
}
|
||||
|
||||
return { user, code };
|
||||
@@ -1224,6 +1237,8 @@ const PROFILE_PUBLIC = {
|
||||
'profile.sex': 1,
|
||||
'profile.born_province': 1,
|
||||
'profile.born_country': 1,
|
||||
'profile.resid_str_comune': 1,
|
||||
'profile.resid_comune': 1,
|
||||
'profile.resid_province': 1,
|
||||
'profile.resid_card': 1,
|
||||
'profile.calc': 1,
|
||||
@@ -5140,6 +5155,8 @@ UserSchema.statics.getLastUsers = async function (idapp) {
|
||||
aportador_solidario: 1,
|
||||
idMyGroup: 1,
|
||||
'profile.img': 1,
|
||||
'profile.resid_str_comune': 1,
|
||||
'profile.resid_comune': 1,
|
||||
'profile.resid_province': 1,
|
||||
date_reg: 1,
|
||||
index: 1,
|
||||
@@ -5148,6 +5165,8 @@ UserSchema.statics.getLastUsers = async function (idapp) {
|
||||
'user_aportador.name': 1,
|
||||
'user_aportador.lasttimeonline': 1,
|
||||
'user_aportador.surname': 1,
|
||||
'user_aportador.profile.resid_str_comune': 1,
|
||||
'user_aportador.profile.resid_comune': 1,
|
||||
'user_aportador.profile.resid_province': 1,
|
||||
'user_aportador.profile.img': 1,
|
||||
},
|
||||
@@ -5185,6 +5204,8 @@ UserSchema.statics.getLastOnlineUsers = async function (idapp) {
|
||||
verified_by_aportador: 1,
|
||||
idMyGroup: 1,
|
||||
'profile.img': 1,
|
||||
'profile.resid_str_comune': 1,
|
||||
'profile.resid_comune': 1,
|
||||
'profile.resid_province': 1,
|
||||
index: 1,
|
||||
}
|
||||
@@ -5255,6 +5276,8 @@ UserSchema.statics.getLastSharedLink = async function (idapp) {
|
||||
aportador_solidario: 1,
|
||||
idMyGroup: 1,
|
||||
'profile.img': 1,
|
||||
'profile.resid_str_comune': 1,
|
||||
'profile.resid_comune': 1,
|
||||
'profile.resid_province': 1,
|
||||
date_reg: 1,
|
||||
index: 1,
|
||||
@@ -5263,6 +5286,8 @@ UserSchema.statics.getLastSharedLink = async function (idapp) {
|
||||
'user_aportador.name': 1,
|
||||
'user_aportador.lasttimeonline': 1,
|
||||
'user_aportador.surname': 1,
|
||||
'user_aportador.profile.resid_str_comune': 1,
|
||||
'user_aportador.profile.resid_comune': 1,
|
||||
'user_aportador.profile.resid_province': 1,
|
||||
'user_aportador.profile.img': 1,
|
||||
},
|
||||
@@ -6809,6 +6834,45 @@ UserSchema.statics.getMyGroupsById = async function (id) {
|
||||
|
||||
return [];
|
||||
};
|
||||
UserSchema.statics.updateProvinceUserByComune = async function (idapp, userId, idcomune) {
|
||||
try {
|
||||
const User = this;
|
||||
|
||||
const { City } = require('../models/city');
|
||||
|
||||
const recCity = await City.getRecCityByIdCity(idcomune);
|
||||
|
||||
const updateData = {
|
||||
'profile.resid_str_comune': recCity ? recCity.comune : '',
|
||||
'profile.resid_province': recCity ? recCity.prov : '',
|
||||
};
|
||||
|
||||
await User.findOneAndUpdate(
|
||||
{ _id: userId },
|
||||
{ $set: updateData },
|
||||
{ new: true }
|
||||
);
|
||||
|
||||
// Ritorna i dati aggiornati nel formato che ti serve
|
||||
return {
|
||||
_id: userId,
|
||||
profile: {
|
||||
resid_str_comune: updateData['profile.resid_str_comune'],
|
||||
resid_province: updateData['profile.resid_province'],
|
||||
},
|
||||
};
|
||||
} catch (e) {
|
||||
console.error('Errore updateProvinceUserByComune', e.message);
|
||||
return {
|
||||
_id: userId,
|
||||
profile: {
|
||||
resid_str_comune: '',
|
||||
resid_province: ''
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
UserSchema.statics.createNewSubRecord = async function (idapp, req) {
|
||||
const User = this;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user