fix Registrazione data
fix linkref fix controllo login
This commit is contained in:
@@ -54,12 +54,18 @@ var ExtraListSchema = new mongoose.Schema({
|
||||
is_in_telegram: {
|
||||
type: Boolean,
|
||||
},
|
||||
is_staff: {
|
||||
type: Boolean,
|
||||
},
|
||||
cell_complete: {
|
||||
type: String
|
||||
},
|
||||
nationality: {
|
||||
type: String
|
||||
},
|
||||
saw_zoom_presentation: {
|
||||
type: Boolean
|
||||
},
|
||||
aportador_solidario_name_surname: {
|
||||
type: String,
|
||||
},
|
||||
@@ -86,26 +92,42 @@ var ExtraListSchema = new mongoose.Schema({
|
||||
});
|
||||
|
||||
ExtraListSchema.methods.toJSON = function () {
|
||||
var user = this;
|
||||
var userObject = user.toObject();
|
||||
const extralist = this;
|
||||
const userObject = extralist.toObject();
|
||||
|
||||
return _.pick(userObject, ['_id', ...shared_consts.fieldsUserToChange()]);
|
||||
};
|
||||
|
||||
ExtraListSchema.statics.findByUsername = function (idapp, username) {
|
||||
const User = this;
|
||||
const ExtraList = this;
|
||||
|
||||
return User.findOne({
|
||||
return ExtraList.findOne({
|
||||
'idapp': idapp,
|
||||
'username': username,
|
||||
});
|
||||
};
|
||||
|
||||
ExtraListSchema.statics.getTotInLista = async function (idapp) {
|
||||
const ExtraList = this;
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await ExtraList.count(myfind);
|
||||
};
|
||||
|
||||
ExtraListSchema.statics.getRegDellaLista = async function (idapp) {
|
||||
const ExtraList = this;
|
||||
|
||||
const myfind = { idapp, registered: true };
|
||||
|
||||
return await ExtraList.count(myfind);
|
||||
};
|
||||
|
||||
|
||||
ExtraListSchema.statics.findByCellAndNameSurname = function (idapp, cell_complete, name, surname) {
|
||||
var User = this;
|
||||
const ExtraList = this;
|
||||
|
||||
return User.findOne({
|
||||
return ExtraList.findOne({
|
||||
'idapp': idapp,
|
||||
'cell_complete': cell_complete,
|
||||
'name': name,
|
||||
@@ -187,24 +209,26 @@ ExtraListSchema.statics.ImportData = async function (locale, idapp, strdata) {
|
||||
if (sep !== '' && row !== '') {
|
||||
let col = row.split(sep);
|
||||
if (col) {
|
||||
if (col.length > 0) {
|
||||
if (col.length > 11) {
|
||||
let user = null;
|
||||
try {
|
||||
user = new ExtraList({
|
||||
idapp: idapp,
|
||||
ind_order: col[0],
|
||||
name_complete: col[2],
|
||||
num_invitati: col[3],
|
||||
is_in_whatsapp: col[4] !== '',
|
||||
is_in_telegram: col[5] !== '',
|
||||
cell_complete: col[6],
|
||||
nationality: col[7],
|
||||
aportador_solidario_name_surname: col[8],
|
||||
aportador_solidario_ind_order: col[9],
|
||||
aportador_solidario_originale_name_surname: col[10],
|
||||
note: col[11],
|
||||
col_b: col[12],
|
||||
col_h: col[13]
|
||||
name_complete: col[2].trim(),
|
||||
num_invitati: col[3].trim(),
|
||||
is_in_whatsapp: col[4].trim() !== '',
|
||||
is_in_telegram: col[5].trim() !== '',
|
||||
is_staff: col[5].trim() === 'VV',
|
||||
saw_zoom_presentation: col[6].trim() !== '',
|
||||
cell_complete: col[7].trim(),
|
||||
nationality: col[8].trim(),
|
||||
aportador_solidario_name_surname: col[9].trim(),
|
||||
aportador_solidario_ind_order: col[10].trim(),
|
||||
aportador_solidario_originale_name_surname: col[11].trim(),
|
||||
note: col[12].trim(),
|
||||
col_b: col[13].trim(),
|
||||
col_h: col[14].trim()
|
||||
});
|
||||
|
||||
try {
|
||||
@@ -213,6 +237,9 @@ ExtraListSchema.statics.ImportData = async function (locale, idapp, strdata) {
|
||||
console.log('error ', e);
|
||||
}
|
||||
|
||||
if (user.cell_complete[0] !== '+')
|
||||
user.cell_complete = '+' + user.cell_complete;
|
||||
|
||||
namesurname = tools.extractNameAndSurnameByComplete(user.name_complete);
|
||||
user.name = namesurname.name;
|
||||
user.surname = namesurname.surname;
|
||||
@@ -235,7 +262,7 @@ ExtraListSchema.statics.ImportData = async function (locale, idapp, strdata) {
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
|
||||
console.log('error ', e);
|
||||
}
|
||||
|
||||
ris = { numadded, numtot, numalreadyexisted };
|
||||
|
||||
@@ -72,7 +72,7 @@ MailingListSchema.statics.getnumSent = async function (idapp, idmailinglist) {
|
||||
|
||||
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||
|
||||
return await MailingList.countDocuments(myfind);
|
||||
return await MailingList.count(myfind);
|
||||
};
|
||||
|
||||
MailingListSchema.statics.isOk = async function (idapp, iduser, idmailinglist) {
|
||||
@@ -82,7 +82,7 @@ MailingListSchema.statics.isOk = async function (idapp, iduser, idmailinglist) {
|
||||
|
||||
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||
|
||||
return await MailingList.countDocuments(myfind) > 0;
|
||||
return await MailingList.count(myfind) > 0;
|
||||
};
|
||||
|
||||
MailingListSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
@@ -44,6 +44,9 @@ const MyPageSchema = new Schema({
|
||||
heightimg: {
|
||||
type: Number,
|
||||
},
|
||||
onlyif_logged: {
|
||||
type: Boolean,
|
||||
},
|
||||
imgback: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
@@ -6,6 +6,8 @@ const _ = require('lodash');
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const { Settings } = require('../models/settings');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
const queryclass = require('../classes/queryclass');
|
||||
|
||||
@@ -23,9 +25,6 @@ const UserSchema = new mongoose.Schema({
|
||||
userId: {
|
||||
type: String,
|
||||
},
|
||||
already_registered: {
|
||||
type: Boolean,
|
||||
},
|
||||
email: {
|
||||
type: String,
|
||||
required: true,
|
||||
@@ -103,7 +102,9 @@ const UserSchema = new mongoose.Schema({
|
||||
},
|
||||
date_reg: {
|
||||
type: Date,
|
||||
default: Date.now()
|
||||
},
|
||||
date_temp_reg: {
|
||||
type: Date,
|
||||
},
|
||||
date_tokenforgot: {
|
||||
type: Date
|
||||
@@ -126,6 +127,9 @@ const UserSchema = new mongoose.Schema({
|
||||
aportador_solidario_ind_order: {
|
||||
type: Number,
|
||||
},
|
||||
note: {
|
||||
type: String,
|
||||
},
|
||||
profile: {
|
||||
img: {
|
||||
type: String
|
||||
@@ -164,6 +168,12 @@ const UserSchema = new mongoose.Schema({
|
||||
dateofbirth: {
|
||||
type: Date,
|
||||
},
|
||||
my_dream: {
|
||||
type: String,
|
||||
},
|
||||
saw_zoom_presentation: {
|
||||
type: Boolean
|
||||
},
|
||||
sex: {
|
||||
type: Number,
|
||||
},
|
||||
@@ -347,7 +357,7 @@ UserSchema.statics.getDownlineByUsername = function (idapp, username) {
|
||||
name: 1,
|
||||
surname: 1,
|
||||
verified_email: 1,
|
||||
made_gift: 11,
|
||||
made_gift: 1,
|
||||
email: 1,
|
||||
date_reg: 1,
|
||||
img: 1
|
||||
@@ -356,6 +366,26 @@ UserSchema.statics.getDownlineByUsername = function (idapp, username) {
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getnumInvitatiAttivi = function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return User.count({
|
||||
idapp,
|
||||
aportador_solidario: username,
|
||||
teleg_id: { $gt: 1 },
|
||||
saw_zoom_presentation: true,
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getnumInvitati = function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return User.count({
|
||||
idapp,
|
||||
aportador_solidario: username,
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.findByLinkreg = function (idapp, linkreg) {
|
||||
const User = this;
|
||||
|
||||
@@ -440,7 +470,7 @@ UserSchema.statics.UserByIdTelegram = async function (idapp, teleg_id) {
|
||||
UserSchema.statics.TelegIdByUsername = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({ idapp, username }, {'profile.teleg_id': 1})
|
||||
return await User.findOne({ idapp, username }, { 'profile.teleg_id': 1 })
|
||||
.then((rec) => {
|
||||
return (!!rec) ? rec.profile.teleg_id : null;
|
||||
}).catch((e) => {
|
||||
@@ -484,7 +514,7 @@ UserSchema.statics.SetTelegramIdSuccess = async function (idapp, username, teleg
|
||||
UserSchema.statics.getNameSurnameByUsername = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({ idapp, username }, {name: 1, surname: 1})
|
||||
return await User.findOne({ idapp, username }, { name: 1, surname: 1 })
|
||||
.then((rec) => {
|
||||
return (!!rec) ? `${rec.name} ${rec.surname}` : '';
|
||||
}).catch((e) => {
|
||||
@@ -493,11 +523,10 @@ UserSchema.statics.getNameSurnameByUsername = async function (idapp, username) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
UserSchema.statics.getusersManagers = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return await User.find({ idapp, 'profile.manage_telegram': true }, {'profile.teleg_id': 1})
|
||||
return await User.find({ idapp, 'profile.manage_telegram': true }, { 'profile.teleg_id': 1 })
|
||||
.then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).catch((e) => {
|
||||
@@ -505,6 +534,29 @@ UserSchema.statics.getusersManagers = async function (idapp) {
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersTelegALL = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return await User.find({ idapp, 'profile.teleg_id': { $gt: 0 } }, { 'profile.teleg_id': 1 })
|
||||
.then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).catch((e) => {
|
||||
console.error('getusersManagers', e);
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.isManagerByIdTeleg = async function (idapp, idtelegram) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({ idapp, 'profile.manage_telegram': true, 'profile.teleg_id': idtelegram }, { 'profile.teleg_id': 1 })
|
||||
.then((rec) => {
|
||||
return (!!rec && rec.profile.teleg_id === idtelegram);
|
||||
}).catch((e) => {
|
||||
console.error('getusersManagers', e);
|
||||
return false
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersList = function (idapp) {
|
||||
const User = this;
|
||||
|
||||
@@ -523,7 +575,6 @@ UserSchema.statics.getUsersList = function (idapp) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
UserSchema.statics.getUsersListByParams = function (params) {
|
||||
const User = this;
|
||||
|
||||
@@ -623,6 +674,46 @@ UserSchema.statics.fixUsername = async function (idapp, aportador_solidario_ind_
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersRegistered = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getLastUsers = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const lastn = await Settings.getValDbSettings(idapp, 'SHOW_LAST_N_USERS', 5);
|
||||
|
||||
return await User.find({ idapp }).sort({ date_temp_reg: -1 }).limit(lastn);
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.checkUser = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({ idapp, username }, {
|
||||
verified_email: 1,
|
||||
'profile.teleg_id': 1,
|
||||
'profile.teleg_checkcode': 1,
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.calculateStat = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return calcstat = {
|
||||
numinvitati: await User.getnumInvitati(idapp, username),
|
||||
numinvitati_attivi: await User.getnumInvitatiAttivi(idapp, username),
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
if (tools.INITDB_FIRSTIME) {
|
||||
console.log(' createIndex User Index...');
|
||||
|
||||
Reference in New Issue
Block a user