Impostato la lingua fissa a ITALIANO: ancora non ci sono le traduzioni e poi qualcosa sul server fa casino (non arrivano le richieste...)
Risolto Bug sui messaggi di registrazione, se l'utente non aveva l'Username Telegram
This commit is contained in:
@@ -4,7 +4,6 @@ const validator = require('validator');
|
||||
const jwt = require('jsonwebtoken');
|
||||
const _ = require('lodash');
|
||||
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const {Settings} = require('../models/settings');
|
||||
@@ -571,7 +570,7 @@ UserSchema.statics.findByCredentials = function(idapp, username, password, pwdcr
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
}).lean();
|
||||
});
|
||||
} else {
|
||||
return !user.deleted || (user.deleted && user.subaccount) ? user : null;
|
||||
}
|
||||
@@ -582,10 +581,10 @@ UserSchema.statics.findByCredentials = function(idapp, username, password, pwdcr
|
||||
pwd = user.password;
|
||||
|
||||
if (pwdcrypted) {
|
||||
if (pwd === user.password){
|
||||
return user
|
||||
if (pwd === user.password) {
|
||||
return user;
|
||||
} else {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -664,6 +663,7 @@ UserSchema.statics.getUserShortDataByUsername = async function(
|
||||
verified_email: 1,
|
||||
verified_by_aportador: 1,
|
||||
'profile.teleg_id': 1,
|
||||
'profile.username_telegram': 1,
|
||||
// 'profile.saw_zoom_presentation': 1,
|
||||
'profile.ask_zoom_partecipato': 1,
|
||||
'profile.qualified': 1,
|
||||
@@ -907,7 +907,6 @@ UserSchema.statics.setVerifiedByAportador = async function(
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.setnotask_verif = async function(
|
||||
@@ -1071,6 +1070,55 @@ UserSchema.statics.findByLinkTokenforgot = function(idapp, email, tokenforgot) {
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.createNewRequestPwd = function(idapp, email) {
|
||||
const User = this;
|
||||
|
||||
const sendemail = require('../sendemail');
|
||||
|
||||
return User.findByEmail(idapp, email).then(async (user) => {
|
||||
if (!user) {
|
||||
return false;
|
||||
} else {
|
||||
// Creo il tokenforgot
|
||||
user.tokenforgot = jwt.sign(user._id.toHexString(), process.env.SIGNCODE).
|
||||
toString();
|
||||
user.date_tokenforgot = new Date();
|
||||
user.lasttimeonline = new Date();
|
||||
return user.save().then(async () => {
|
||||
await sendemail.sendEmail_RequestNewPassword(user.lang, user, user.email, user.idapp, user.tokenforgot);
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.createNewRequestPwdByUsernameAndGetLink = async function(idapp, username) {
|
||||
const User = this;
|
||||
|
||||
const user = await User.findOne({
|
||||
idapp,
|
||||
username,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
});
|
||||
|
||||
if (user) {
|
||||
// Creo il tokenforgot
|
||||
user.tokenforgot = jwt.sign(user._id.toHexString(), process.env.SIGNCODE).
|
||||
toString();
|
||||
user.date_tokenforgot = new Date();
|
||||
user.lasttimeonline = new Date();
|
||||
|
||||
return user.save().then(() => {
|
||||
return tools.getlinkRequestNewPassword(idapp, user.email, user.tokenforgot);
|
||||
});
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.findByEmail = function(idapp, email, onlyifVerifiedByAportador) {
|
||||
const User = this;
|
||||
|
||||
@@ -1976,7 +2024,7 @@ UserSchema.statics.notAsk_VerifByUsername = async function(idapp, username) {
|
||||
idapp, username,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}, {'notask_verif': 1}).lean().then((rec) => {
|
||||
return (!!rec && rec.notask_verif) ? true: false;
|
||||
return (!!rec && rec.notask_verif) ? true : false;
|
||||
}).catch((e) => {
|
||||
console.error('notAsk_VerifByUsername', e);
|
||||
return false;
|
||||
@@ -2052,7 +2100,6 @@ UserSchema.statics.setUsernameTelegram = async function(
|
||||
|
||||
};
|
||||
|
||||
|
||||
UserSchema.statics.SetLang = async function(idapp, id, lang) {
|
||||
const User = this;
|
||||
|
||||
@@ -2155,7 +2202,6 @@ UserSchema.statics.getNameSurnameById = async function(idapp, userId) {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
UserSchema.statics.getusersManagers = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
@@ -2219,11 +2265,10 @@ UserSchema.statics.getUsersTelegALL = async function(idapp, username) {
|
||||
const User = this;
|
||||
|
||||
if (!!username) {
|
||||
return User.find({idapp, username, 'profile.teleg_id': {$gt: 0}})
|
||||
.lean()
|
||||
then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).
|
||||
return User.find({idapp, username, 'profile.teleg_id': {$gt: 0}}).lean();
|
||||
then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).
|
||||
catch((e) => {
|
||||
console.error('getUsersTelegALL', e);
|
||||
});
|
||||
@@ -2315,8 +2360,8 @@ UserSchema.statics.getFieldsForSearch = function() {
|
||||
{field: 'profile.link_payment', type: tools.FieldType.string},
|
||||
{field: 'profile.teleg_id', type: tools.FieldType.number},
|
||||
{field: 'profile.username_telegram', type: tools.FieldType.string},
|
||||
{field: 'ipaddr', type: tools.FieldType.string}
|
||||
];
|
||||
{field: 'ipaddr', type: tools.FieldType.string},
|
||||
];
|
||||
//{field: 'aportador_solidario', type: tools.FieldType.string}
|
||||
};
|
||||
|
||||
@@ -2555,6 +2600,32 @@ UserSchema.statics.getUsersTelegramAttivo = async function(idapp) {
|
||||
return User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersAutorizzati = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = {
|
||||
idapp,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
'profile.teleg_id': {$gt: 0},
|
||||
verified_by_aportador: true,
|
||||
};
|
||||
|
||||
return User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersAutorizzare = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = {
|
||||
idapp,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
'profile.teleg_id': {$gt: 0},
|
||||
$or: [{verified_by_aportador: {$exists: false}}, {verified_by_aportador: {$exists: true, $eq: false}}],
|
||||
};
|
||||
|
||||
return User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersTelegramPending = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
@@ -2692,7 +2763,7 @@ UserSchema.statics.calculateStat = async function(idapp, username) {
|
||||
|
||||
const numGroups = await MyGroup.countDocuments({idapp});
|
||||
|
||||
let numByTab = {}
|
||||
let numByTab = {};
|
||||
|
||||
const globalTables = require('../tools/globalTables');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user