diff --git a/emails/RISO/reg_chiedi_ammettere_all_invitante/it/html.pug b/emails/RISO/reg_chiedi_ammettere_all_invitante/it/html.pug index 56b096a..19f63bf 100755 --- a/emails/RISO/reg_chiedi_ammettere_all_invitante/it/html.pug +++ b/emails/RISO/reg_chiedi_ammettere_all_invitante/it/html.pug @@ -317,6 +317,10 @@ html(lang="it") .member-detail strong Email: | #{emailInvitato} + if userprofile && userprofile.profile.resid_str_comune && userprofile.profile.resid_province + .member-detail + strong Comune Residenza: + | #{userprofile.profile.resid_str_comune} (#{userprofile.profile.resid_province}) //- Domanda di conferma .question-box diff --git a/emails/admin/registration/it/html.pug b/emails/admin/registration/it/html.pug index 45e0f03..8e88e80 100755 --- a/emails/admin/registration/it/html.pug +++ b/emails/admin/registration/it/html.pug @@ -158,6 +158,12 @@ html(lang="it") .info-value | #{user.profile.intcode_cell || ''} #{user.profile.cell || ''} + if user && user.profile && (user.profile.resid_str_comune && user.profile.resid_province) + .info-row + .info-label Comune di Residenza: + .info-value + | #{user.profile.resid_str_comune || ''} (#{user.profile.resid_province || ''}) + if user && user.profile && user.profile.nationality .info-row .info-label Nazionalità: diff --git a/emails/defaultSite/reg_chiedi_ammettere_all_invitante/it/html.pug b/emails/defaultSite/reg_chiedi_ammettere_all_invitante/it/html.pug index 46ed5d1..e9eb7f5 100755 --- a/emails/defaultSite/reg_chiedi_ammettere_all_invitante/it/html.pug +++ b/emails/defaultSite/reg_chiedi_ammettere_all_invitante/it/html.pug @@ -317,6 +317,10 @@ html(lang="it") .member-detail strong Email: | #{emailInvitato} + if userprofile && userprofile.profile.resid_str_comune && userprofile.profile.resid_province + .member-detail + strong Comune Residenza: + | #{userprofile.profile.resid_str_comune} (#{userprofile.profile.resid_province}) //- Domanda di conferma .question-box diff --git a/src/models/user.js b/src/models/user.js index 681acdf..36f3bdc 100755 --- a/src/models/user.js +++ b/src/models/user.js @@ -932,13 +932,12 @@ 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); @@ -4443,6 +4442,20 @@ UserSchema.statics.getNameSurnameEUsernameByUsername = async function (idapp, us console.error('getNameSurnameByUsername', e); }); }; +UserSchema.statics.getProfileByUsername = async function (idapp, username, reale = false) { + const User = this; + + return await User.findOne( + { + idapp, + username, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], + }, + { profile: 1 } + ).catch((e) => { + console.error('getNameSurnameByUsername', e); + }); +}; UserSchema.statics.getIdByUsername = async function (idapp, username) { const User = this; @@ -6849,11 +6862,7 @@ UserSchema.statics.updateProvinceUserByComune = async function (idapp, userId, i 'profile.resid_province': recCity ? recCity.prov : '', }; - await User.findOneAndUpdate( - { _id: userId }, - { $set: updateData }, - { new: true } - ); + await User.findOneAndUpdate({ _id: userId }, { $set: updateData }, { new: true }); // Ritorna i dati aggiornati nel formato che ti serve return { @@ -6865,12 +6874,12 @@ UserSchema.statics.updateProvinceUserByComune = async function (idapp, userId, i }; } catch (e) { console.error('Errore updateProvinceUserByComune', e.message); - return { + return { _id: userId, profile: { - resid_str_comune: '', - resid_province: '' - } + resid_str_comune: '', + resid_province: '', + }, }; } }; diff --git a/src/sendemail.js b/src/sendemail.js index eab6b43..c57b616 100755 --- a/src/sendemail.js +++ b/src/sendemail.js @@ -543,6 +543,7 @@ module.exports = { usernameInvitante: user.aportador_solidario, nomeInvitante: nomecognomeInvitante.trim(), nomeInvitato: await User.getNameSurnameEUsernameByUsername(idapp, user.username), + userprofile: await User.getProfileByUsername(idapp, user.username), usernameInvitato: user.username, emailInvitato: user.email, user,