Protetto le password (al load) che vengono settate in settings
This commit is contained in:
@@ -364,7 +364,7 @@ UserSchema.statics.setZoomPresenza = async function(idapp, id, presenza) {
|
||||
allData.precDataUser = await User.getInfoUser(idapp,
|
||||
allData.myuser.username);
|
||||
|
||||
return await User.findByIdAndUpdate(id,
|
||||
return User.findByIdAndUpdate(id,
|
||||
{$set: {'profile.saw_zoom_presentation': presenza}}).then((rec) => {
|
||||
if (presenza) {
|
||||
const messaggio = tools.get__('ZOOM_CONFERMATO');
|
||||
@@ -1086,7 +1086,7 @@ UserSchema.methods.removeToken = function(token) {
|
||||
UserSchema.statics.getEmailByUsername = async function(idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
return User.findOne({
|
||||
idapp, username,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}).then((arrrec) => {
|
||||
@@ -1099,7 +1099,7 @@ UserSchema.statics.getEmailByUsername = async function(idapp, username) {
|
||||
UserSchema.statics.getUsernameById = async function(idapp, id) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
return User.findOne({
|
||||
idapp, _id: id,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}, {username: 1}).then((myuser) => {
|
||||
@@ -1122,7 +1122,7 @@ UserSchema.statics.getAportadorSolidarioByUsername = async function(
|
||||
idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
return User.findOne({
|
||||
idapp, username,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}).then((rec) => {
|
||||
@@ -1135,7 +1135,7 @@ UserSchema.statics.getAportadorSolidarioByUsername = async function(
|
||||
UserSchema.statics.UserByIdTelegram = async function(idapp, teleg_id) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
return User.findOne({
|
||||
idapp, 'profile.teleg_id': teleg_id,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}).then((rec) => {
|
||||
@@ -1148,7 +1148,7 @@ UserSchema.statics.UserByIdTelegram = async function(idapp, teleg_id) {
|
||||
UserSchema.statics.UsersByIdTelegram = async function(idapp, teleg_id) {
|
||||
const User = this;
|
||||
|
||||
return await User.find({
|
||||
return User.find({
|
||||
idapp, 'profile.teleg_id': teleg_id,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}).then((rec) => {
|
||||
@@ -1161,7 +1161,7 @@ UserSchema.statics.UsersByIdTelegram = async function(idapp, teleg_id) {
|
||||
UserSchema.statics.TelegIdByUsername = async function(idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
return User.findOne({
|
||||
idapp, username,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}, {'profile.teleg_id': 1}).then((rec) => {
|
||||
@@ -1179,7 +1179,7 @@ UserSchema.statics.SetTelegramCheckCode = async function(
|
||||
'profile.teleg_checkcode': teleg_checkcode,
|
||||
};
|
||||
|
||||
return await User.findOneAndUpdate({
|
||||
return User.findOneAndUpdate({
|
||||
_id: id,
|
||||
}, {$set: fields_to_update}, {new: false}).then((record) => {
|
||||
return !!record;
|
||||
@@ -1194,7 +1194,7 @@ UserSchema.statics.NonVoglioImbarcarmi = async function(idapp, username) {
|
||||
non_voglio_imbarcarmi: true,
|
||||
};
|
||||
|
||||
return await User.findOneAndUpdate({
|
||||
return User.findOneAndUpdate({
|
||||
idapp,
|
||||
username,
|
||||
}, {$set: fields_to_update}, {new: false}).then((record) => {
|
||||
@@ -1212,7 +1212,7 @@ UserSchema.statics.SetTelegramIdSuccess = async function(idapp, id, teleg_id) {
|
||||
'profile.teleg_checkcode': 0,
|
||||
};
|
||||
|
||||
return await User.findOneAndUpdate({
|
||||
return User.findOneAndUpdate({
|
||||
idapp,
|
||||
_id: id,
|
||||
}, {$set: fields_to_update}, {new: false}).then((record) => {
|
||||
@@ -1236,7 +1236,7 @@ UserSchema.statics.SetLang = async function(idapp, id, lang) {
|
||||
lang,
|
||||
};
|
||||
|
||||
return await User.findOneAndUpdate({
|
||||
return User.findOneAndUpdate({
|
||||
_id: id,
|
||||
}, {$set: fields_to_update}, {new: false}).then((record) => {
|
||||
return record;
|
||||
@@ -1267,7 +1267,7 @@ UserSchema.statics.SetTelegramWasBlocked = async function(idapp, teleg_id) {
|
||||
UserSchema.statics.getNameSurnameByUsername = async function(idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
return User.findOne({
|
||||
idapp, username,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}, {name: 1, surname: 1}).then((rec) => {
|
||||
@@ -1280,7 +1280,7 @@ UserSchema.statics.getNameSurnameByUsername = async function(idapp, username) {
|
||||
UserSchema.statics.getNameSurnameById = async function(idapp, userId) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
return User.findOne({
|
||||
idapp,
|
||||
_id: userId,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
@@ -1384,7 +1384,7 @@ UserSchema.statics.getRecByIndOrder = async function(idapp, ind_order) {
|
||||
UserSchema.statics.getusersManagers = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
return await User.find({idapp, 'profile.manage_telegram': true},
|
||||
return User.find({idapp, 'profile.manage_telegram': true},
|
||||
{'profile.teleg_id': 1, perm: 1}).then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).catch((e) => {
|
||||
@@ -1395,7 +1395,7 @@ UserSchema.statics.getusersManagers = async function(idapp) {
|
||||
UserSchema.statics.getusersRespList = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
return await User.find({idapp, 'profile.resplist': true},
|
||||
return User.find({idapp, 'profile.resplist': true},
|
||||
{_id: 1, username: 1, name: 1, surname: 1}).then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).catch((e) => {
|
||||
@@ -1406,7 +1406,7 @@ UserSchema.statics.getusersRespList = async function(idapp) {
|
||||
UserSchema.statics.getusersWorkersList = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
return await User.find({idapp, 'profile.workerslist': true},
|
||||
return User.find({idapp, 'profile.workerslist': true},
|
||||
{_id: 1, username: 1, name: 1, surname: 1}).then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).catch((e) => {
|
||||
@@ -1417,7 +1417,7 @@ UserSchema.statics.getusersWorkersList = async function(idapp) {
|
||||
UserSchema.statics.getusersManagersAndZoomeri = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
return await User.find(
|
||||
return User.find(
|
||||
{
|
||||
idapp,
|
||||
or: [
|
||||
@@ -1444,7 +1444,7 @@ UserSchema.statics.getUsersTelegALL = async function(idapp, username) {
|
||||
const User = this;
|
||||
|
||||
if (!!username) {
|
||||
return await User.find({idapp, username, 'profile.teleg_id': {$gt: 0}}).
|
||||
return User.find({idapp, username, 'profile.teleg_id': {$gt: 0}}).
|
||||
then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).
|
||||
@@ -1452,7 +1452,7 @@ UserSchema.statics.getUsersTelegALL = async function(idapp, username) {
|
||||
console.error('getUsersTelegALL', e);
|
||||
});
|
||||
} else {
|
||||
return await User.find({idapp, 'profile.teleg_id': {$gt: 0}}).
|
||||
return User.find({idapp, 'profile.teleg_id': {$gt: 0}}).
|
||||
then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).
|
||||
@@ -1466,7 +1466,7 @@ UserSchema.statics.getUsersTelegALL = async function(idapp, username) {
|
||||
UserSchema.statics.isManagerByIdTeleg = async function(idapp, idtelegram) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
return User.findOne({
|
||||
idapp,
|
||||
'profile.manage_telegram': true,
|
||||
'profile.teleg_id': idtelegram,
|
||||
@@ -1481,7 +1481,7 @@ UserSchema.statics.isManagerByIdTeleg = async function(idapp, idtelegram) {
|
||||
UserSchema.statics.isAdminByIdTeleg = async function(idapp, idtelegram) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
return User.findOne({
|
||||
idapp,
|
||||
username: 'paoloar77',
|
||||
'profile.manage_telegram': true,
|
||||
@@ -1545,7 +1545,7 @@ UserSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
UserSchema.statics.findAllIdApp = function(idapp) {
|
||||
UserSchema.statics.findAllIdApp = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = {
|
||||
@@ -1767,7 +1767,7 @@ UserSchema.statics.getUsersRegistered = async function(idapp) {
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
};
|
||||
|
||||
return await User.count(myfind);
|
||||
return User.count(myfind);
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -1962,7 +1962,7 @@ UserSchema.statics.getEmailNotVerified = async function(idapp) {
|
||||
verified_email: false,
|
||||
};
|
||||
|
||||
return await User.count(myfind);
|
||||
return User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersTelegramAttivo = async function(idapp) {
|
||||
@@ -1974,7 +1974,7 @@ UserSchema.statics.getUsersTelegramAttivo = async function(idapp) {
|
||||
'profile.teleg_id': {$gt: 0},
|
||||
};
|
||||
|
||||
return await User.count(myfind);
|
||||
return User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersTelegramPending = async function(idapp) {
|
||||
@@ -1986,7 +1986,7 @@ UserSchema.statics.getUsersTelegramPending = async function(idapp) {
|
||||
'profile.teleg_checkcode': {$gt: 0},
|
||||
};
|
||||
|
||||
return await User.count(myfind);
|
||||
return User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersZoom = async function(idapp) {
|
||||
@@ -1998,7 +1998,7 @@ UserSchema.statics.getUsersZoom = async function(idapp) {
|
||||
'profile.saw_zoom_presentation': true,
|
||||
};
|
||||
|
||||
return await User.count(myfind);
|
||||
return User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersResidenti = async function(idapp) {
|
||||
@@ -2010,7 +2010,7 @@ UserSchema.statics.getUsersResidenti = async function(idapp) {
|
||||
'profile.socioresidente': {$exists: true, $eq: true},
|
||||
};
|
||||
|
||||
return await User.find(myfind, {username: 1, name: 1, surname: 1});
|
||||
return User.find(myfind, {username: 1, name: 1, surname: 1});
|
||||
};
|
||||
|
||||
UserSchema.statics.getSaw_and_Accepted = async function(idapp) {
|
||||
@@ -2022,7 +2022,7 @@ UserSchema.statics.getSaw_and_Accepted = async function(idapp) {
|
||||
'profile.saw_and_accepted': shared_consts.ALL_SAW_AND_ACCEPTED,
|
||||
};
|
||||
|
||||
return await User.count(myfind);
|
||||
return User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersDreams = async function(idapp) {
|
||||
@@ -2035,7 +2035,7 @@ UserSchema.statics.getUsersDreams = async function(idapp) {
|
||||
'$expr': {'$gt': [{'$strLenCP': '$profile.my_dream'}, 10]},
|
||||
};
|
||||
|
||||
return await User.count(myfind);
|
||||
return User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getLastUsers = async function(idapp) {
|
||||
@@ -2043,7 +2043,7 @@ UserSchema.statics.getLastUsers = async function(idapp) {
|
||||
|
||||
const lastn = await Settings.getValDbSettings(idapp, 'SHOW_LAST_N_USERS', 5);
|
||||
|
||||
return await User.find(
|
||||
return User.find(
|
||||
{
|
||||
idapp,
|
||||
$or: [
|
||||
@@ -2067,7 +2067,7 @@ UserSchema.statics.getLastUsers = async function(idapp) {
|
||||
UserSchema.statics.checkUser = async function(idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({idapp, username}, {
|
||||
return User.findOne({idapp, username}, {
|
||||
verified_email: 1,
|
||||
'profile.teleg_id': 1,
|
||||
'profile.teleg_checkcode': 1,
|
||||
@@ -2213,7 +2213,7 @@ UserSchema.statics.getnumRegNDays = function(idapp, nrec) {
|
||||
UserSchema.statics.calcnumRegUntilDay = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
return await User.aggregate(User.getnumRegNDays(idapp, 30)).then((arr) => {
|
||||
return User.aggregate(User.getnumRegNDays(idapp, 30)).then((arr) => {
|
||||
return arr.reduce((sum, rec) => sum + rec.count, 0);
|
||||
});
|
||||
|
||||
@@ -2456,12 +2456,10 @@ UserSchema.statics.checkIfSbloccatiRequisiti = async function(
|
||||
!await User.isUserAlreadyQualified_2Invitati(idapp,
|
||||
allData.myuser.username)) {
|
||||
await User.setUserQualified_2Invitati(idapp, allData.myuser.username);
|
||||
|
||||
// ORA HAI I 9 REQUISITI !
|
||||
const msgtext = telegrambot.getCiao(idapp, allData.myuser.username,
|
||||
allData.myuser.lang) +
|
||||
tools.gettranslate('HAI_I_9_REQUISITI', allData.myuser.lang);
|
||||
telegrambot.sendMsgTelegram(idapp, allData.myuser.username, msgtext,
|
||||
false); // Anche a STAFF
|
||||
// const msgtext = telegrambot.getCiao(idapp, allData.myuser.username, allData.myuser.lang) + tools.gettranslate('HAI_I_9_REQUISITI', allData.myuser.lang);
|
||||
// telegrambot.sendMsgTelegram(idapp, allData.myuser.username, msgtext, false); // Anche a STAFF
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2655,7 +2653,7 @@ UserSchema.statics.DbOp = async function(idapp, mydata) {
|
||||
|
||||
return {num};
|
||||
|
||||
// return await User.updateMany({ idapp }, { $set: { 'profile.cell': { $concat: ["$profile.intcode_cell", "$profile.cell"] } } })
|
||||
// return User.updateMany({ idapp }, { $set: { 'profile.cell': { $concat: ["$profile.intcode_cell", "$profile.cell"] } } })
|
||||
} else if (mydata.dbop === 'changeEmailLowerCase') {
|
||||
arrusers = await User.find({'idapp': idapp});
|
||||
let num = 0;
|
||||
|
||||
Reference in New Issue
Block a user