- Corretto campo "Comune di Residenza".
- Aggiornato Completamento Profilo: Comune di Residenza. - Registrazione
This commit is contained in:
@@ -81,6 +81,10 @@ CitySchema.statics.getProvinceByIdCity = async function (idcity) {
|
|||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
CitySchema.statics.getRecCityByIdCity = async function (idcity) {
|
||||||
|
const myrec = await City.findOne({ _id: idcity }).lean();
|
||||||
|
return myrec;
|
||||||
|
}
|
||||||
|
|
||||||
CitySchema.statics.getCircuitNameBystrProv = async function (strProv) {
|
CitySchema.statics.getCircuitNameBystrProv = async function (strProv) {
|
||||||
const { Circuit } = require('../models/circuit');
|
const { Circuit } = require('../models/circuit');
|
||||||
|
|||||||
@@ -120,6 +120,9 @@ const SiteSchema = new Schema({
|
|||||||
telegram_support_chat: {
|
telegram_support_chat: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
telegram_gruppi_territoriali_senzainvito: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
pathreg_add: {
|
pathreg_add: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -511,6 +511,16 @@ const UserSchema = new mongoose.Schema({
|
|||||||
resid_prov_id: {
|
resid_prov_id: {
|
||||||
type: Number,
|
type: Number,
|
||||||
},
|
},
|
||||||
|
resid_comune: {
|
||||||
|
type: String,
|
||||||
|
trim: true,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
resid_str_comune: {
|
||||||
|
type: String,
|
||||||
|
trim: true,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
resid_province: {
|
resid_province: {
|
||||||
type: String,
|
type: String,
|
||||||
trim: true,
|
trim: true,
|
||||||
@@ -928,6 +938,7 @@ UserSchema.statics.findByToken = async function (
|
|||||||
project
|
project
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Verifica scadenza token per idapp specifici
|
// Verifica scadenza token per idapp specifici
|
||||||
if (user) {
|
if (user) {
|
||||||
const checkExpiry = tools.getEnableTokenExpiredByIdApp(user.idapp);
|
const checkExpiry = tools.getEnableTokenExpiredByIdApp(user.idapp);
|
||||||
@@ -937,6 +948,8 @@ UserSchema.statics.findByToken = async function (
|
|||||||
console.log('🔴 Il token è scaduto, generazione del nuovo token...');
|
console.log('🔴 Il token è scaduto, generazione del nuovo token...');
|
||||||
code = server_constants.RIS_CODE_HTTP_TOKEN_EXPIRED;
|
code = server_constants.RIS_CODE_HTTP_TOKEN_EXPIRED;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
code = server_constants.RIS_CODE_HTTP_INVALID_TOKEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { user, code };
|
return { user, code };
|
||||||
@@ -1224,6 +1237,8 @@ const PROFILE_PUBLIC = {
|
|||||||
'profile.sex': 1,
|
'profile.sex': 1,
|
||||||
'profile.born_province': 1,
|
'profile.born_province': 1,
|
||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
|
'profile.resid_str_comune': 1,
|
||||||
|
'profile.resid_comune': 1,
|
||||||
'profile.resid_province': 1,
|
'profile.resid_province': 1,
|
||||||
'profile.resid_card': 1,
|
'profile.resid_card': 1,
|
||||||
'profile.calc': 1,
|
'profile.calc': 1,
|
||||||
@@ -5140,6 +5155,8 @@ UserSchema.statics.getLastUsers = async function (idapp) {
|
|||||||
aportador_solidario: 1,
|
aportador_solidario: 1,
|
||||||
idMyGroup: 1,
|
idMyGroup: 1,
|
||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
|
'profile.resid_str_comune': 1,
|
||||||
|
'profile.resid_comune': 1,
|
||||||
'profile.resid_province': 1,
|
'profile.resid_province': 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
index: 1,
|
index: 1,
|
||||||
@@ -5148,6 +5165,8 @@ UserSchema.statics.getLastUsers = async function (idapp) {
|
|||||||
'user_aportador.name': 1,
|
'user_aportador.name': 1,
|
||||||
'user_aportador.lasttimeonline': 1,
|
'user_aportador.lasttimeonline': 1,
|
||||||
'user_aportador.surname': 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.resid_province': 1,
|
||||||
'user_aportador.profile.img': 1,
|
'user_aportador.profile.img': 1,
|
||||||
},
|
},
|
||||||
@@ -5185,6 +5204,8 @@ UserSchema.statics.getLastOnlineUsers = async function (idapp) {
|
|||||||
verified_by_aportador: 1,
|
verified_by_aportador: 1,
|
||||||
idMyGroup: 1,
|
idMyGroup: 1,
|
||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
|
'profile.resid_str_comune': 1,
|
||||||
|
'profile.resid_comune': 1,
|
||||||
'profile.resid_province': 1,
|
'profile.resid_province': 1,
|
||||||
index: 1,
|
index: 1,
|
||||||
}
|
}
|
||||||
@@ -5255,6 +5276,8 @@ UserSchema.statics.getLastSharedLink = async function (idapp) {
|
|||||||
aportador_solidario: 1,
|
aportador_solidario: 1,
|
||||||
idMyGroup: 1,
|
idMyGroup: 1,
|
||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
|
'profile.resid_str_comune': 1,
|
||||||
|
'profile.resid_comune': 1,
|
||||||
'profile.resid_province': 1,
|
'profile.resid_province': 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
index: 1,
|
index: 1,
|
||||||
@@ -5263,6 +5286,8 @@ UserSchema.statics.getLastSharedLink = async function (idapp) {
|
|||||||
'user_aportador.name': 1,
|
'user_aportador.name': 1,
|
||||||
'user_aportador.lasttimeonline': 1,
|
'user_aportador.lasttimeonline': 1,
|
||||||
'user_aportador.surname': 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.resid_province': 1,
|
||||||
'user_aportador.profile.img': 1,
|
'user_aportador.profile.img': 1,
|
||||||
},
|
},
|
||||||
@@ -6809,6 +6834,45 @@ UserSchema.statics.getMyGroupsById = async function (id) {
|
|||||||
|
|
||||||
return [];
|
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) {
|
UserSchema.statics.createNewSubRecord = async function (idapp, req) {
|
||||||
const User = this;
|
const User = this;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ const router = express.Router(),
|
|||||||
|
|
||||||
const telegrambot = require('../telegram/telegrambot');
|
const telegrambot = require('../telegram/telegrambot');
|
||||||
|
|
||||||
|
|
||||||
const i18n = require('i18n');
|
const i18n = require('i18n');
|
||||||
|
|
||||||
const sharp = require('sharp');
|
const sharp = require('sharp');
|
||||||
@@ -57,6 +56,7 @@ const { Skill } = require('../models/skill');
|
|||||||
const { Good } = require('../models/good');
|
const { Good } = require('../models/good');
|
||||||
const { StatusSkill } = require('../models/statusSkill');
|
const { StatusSkill } = require('../models/statusSkill');
|
||||||
const { Province } = require('../models/province');
|
const { Province } = require('../models/province');
|
||||||
|
const { City } = require('../models/city');
|
||||||
const { Sector } = require('../models/sector');
|
const { Sector } = require('../models/sector');
|
||||||
const { SectorGood } = require('../models/sectorgood');
|
const { SectorGood } = require('../models/sectorgood');
|
||||||
const { CatGrp } = require('../models/catgrp');
|
const { CatGrp } = require('../models/catgrp');
|
||||||
@@ -156,7 +156,7 @@ router.post('/ammetti', (req, res) => {
|
|||||||
const myuser = user;
|
const myuser = user;
|
||||||
const dati = {
|
const dati = {
|
||||||
token,
|
token,
|
||||||
}
|
};
|
||||||
|
|
||||||
const msgOrig = i18n.__(
|
const msgOrig = i18n.__(
|
||||||
{ phrase: '✅ Sei stato Ammesso correttamente da %s!', locale: lang },
|
{ phrase: '✅ Sei stato Ammesso correttamente da %s!', locale: lang },
|
||||||
@@ -1447,6 +1447,8 @@ router.patch('/chval', authenticate, async (req, res) => {
|
|||||||
let flotta = null;
|
let flotta = null;
|
||||||
let strflotta = '';
|
let strflotta = '';
|
||||||
|
|
||||||
|
let profileData = {};
|
||||||
|
|
||||||
if (shared_consts.TABLES_UPDATE_LASTMODIFIED.includes(mydata.table)) {
|
if (shared_consts.TABLES_UPDATE_LASTMODIFIED.includes(mydata.table)) {
|
||||||
fieldsvalue.date_updated = new Date();
|
fieldsvalue.date_updated = new Date();
|
||||||
}
|
}
|
||||||
@@ -1588,10 +1590,20 @@ router.patch('/chval', authenticate, async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mydata.table === 'users') {
|
if (mydata.table === 'users') {
|
||||||
if ('profile.resid_province' in fieldsvalue) {
|
let provincia = '';
|
||||||
|
|
||||||
|
if ('profile.resid_comune' in fieldsvalue) {
|
||||||
|
const idcomune = fieldsvalue['profile.resid_comune'];
|
||||||
|
|
||||||
|
profileData = await User.updateProvinceUserByComune(idapp, id, idcomune);
|
||||||
|
|
||||||
|
provincia = profileData['profile.resid_province'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (provincia) {
|
||||||
const card = fieldsvalue.hasOwnProperty('profile.resid_card') ? fieldsvalue['profile.resid_card'] : '';
|
const card = fieldsvalue.hasOwnProperty('profile.resid_card') ? fieldsvalue['profile.resid_card'] : '';
|
||||||
// Controlla se esiste il Circuito di questa provincia, se non esiste lo crea!
|
// Controlla se esiste il Circuito di questa provincia, se non esiste lo crea!
|
||||||
await Circuit.createCircuitIfNotExist(req, idapp, fieldsvalue['profile.resid_province'], card);
|
await Circuit.createCircuitIfNotExist(req, idapp, provincia, card);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (camporequisiti) {
|
if (camporequisiti) {
|
||||||
@@ -1669,7 +1681,7 @@ router.patch('/chval', authenticate, async (req, res) => {
|
|||||||
if (msg !== '') telegrambot.sendMsgTelegramToTheManagers(idapp, msg);
|
if (msg !== '') telegrambot.sendMsgTelegramToTheManagers(idapp, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
|
res.send({ code: server_constants.RIS_CODE_OK, msg: '', profileData });
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
|
|||||||
@@ -2146,6 +2146,14 @@ module.exports = {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
getLinkGruppiTerritorialiTelegram: function (idapp) {
|
||||||
|
try {
|
||||||
|
const myapp = this.MYAPPS.find((item) => item.idapp === idapp);
|
||||||
|
return myapp && myapp.telegram_gruppi_territoriali_senzainvito ? myapp.telegram_gruppi_territoriali_senzainvito : '';
|
||||||
|
} catch (e) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
getTelegramKeyByIdApp: function (idapp) {
|
getTelegramKeyByIdApp: function (idapp) {
|
||||||
if (this.MYAPPS.length === 0) {
|
if (this.MYAPPS.length === 0) {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.2.84
|
1.2.85
|
||||||
Reference in New Issue
Block a user