"Riregistrarsi se l'invitante non ha ancora confermato l'invito.
Annullo la richiesta precedente. (inviando un msg di annullamento. (Si è già registrato con un alto invito.)"
This commit is contained in:
@@ -546,7 +546,7 @@ UserSchema.statics.findByTokenAnyAccess = function(token) {
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.findByCredentials = function(idapp, username, password) {
|
||||
UserSchema.statics.findByCredentials = function(idapp, username, password, pwdcrypted) {
|
||||
const User = this;
|
||||
let pwd = '';
|
||||
|
||||
@@ -571,7 +571,7 @@ UserSchema.statics.findByCredentials = function(idapp, username, password) {
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
});
|
||||
}).lean();
|
||||
} else {
|
||||
return !user.deleted || (user.deleted && user.subaccount) ? user : null;
|
||||
}
|
||||
@@ -581,6 +581,14 @@ UserSchema.statics.findByCredentials = function(idapp, username, password) {
|
||||
|
||||
pwd = user.password;
|
||||
|
||||
if (pwdcrypted) {
|
||||
if (pwd === user.password){
|
||||
return user
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
// Use bcrypt.compare to compare password and user.password
|
||||
// console.log("pwd1 " + password);
|
||||
@@ -596,7 +604,7 @@ UserSchema.statics.findByCredentials = function(idapp, username, password) {
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.findByUsername = async function(idapp, username, alsoemail) {
|
||||
UserSchema.statics.findByUsername = async function(idapp, username, alsoemail, onlyifVerifiedByAportador) {
|
||||
const User = this;
|
||||
|
||||
const myreg = ['^', username, '$'].join('');
|
||||
@@ -621,6 +629,16 @@ UserSchema.statics.findByUsername = async function(idapp, username, alsoemail) {
|
||||
});
|
||||
}
|
||||
return ris;
|
||||
}).then((rec) => {
|
||||
if (onlyifVerifiedByAportador) {
|
||||
if (tools.getAskToVerifyReg(idapp)) {
|
||||
if (!rec.verified_by_aportador)
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return rec;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -910,6 +928,24 @@ UserSchema.statics.setnotask_verif = async function(
|
||||
return !!myrec;
|
||||
};
|
||||
|
||||
UserSchema.statics.setaportador_solidario = async function(
|
||||
idapp, username, usernameAportador) {
|
||||
const User = this;
|
||||
|
||||
if (username === undefined)
|
||||
return false;
|
||||
|
||||
const myquery = {
|
||||
'idapp': idapp,
|
||||
'username': username,
|
||||
};
|
||||
|
||||
const myrec = await User.findOneAndUpdate(myquery,
|
||||
{$set: {'aportador_solidario': usernameAportador}}, {new: false});
|
||||
|
||||
return !!myrec;
|
||||
};
|
||||
|
||||
UserSchema.statics.setVerifiedByAportadorToALL = async function() {
|
||||
|
||||
return User.updateMany({}, {$set: {'verified_by_aportador': true}},
|
||||
@@ -1035,13 +1071,23 @@ UserSchema.statics.findByLinkTokenforgot = function(idapp, email, tokenforgot) {
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.findByEmail = function(idapp, email) {
|
||||
UserSchema.statics.findByEmail = function(idapp, email, onlyifVerifiedByAportador) {
|
||||
const User = this;
|
||||
|
||||
return User.findOne({
|
||||
'idapp': idapp,
|
||||
'email': email,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}).then((rec) => {
|
||||
if (onlyifVerifiedByAportador) {
|
||||
if (tools.getAskToVerifyReg(idapp)) {
|
||||
if (!rec.verified_by_aportador)
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return rec;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -3092,7 +3138,7 @@ UserSchema.statics.convSubAccount = async function(idapp) {
|
||||
UserSchema.statics.getLastRec = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
lastrec = await User.find({idapp}).sort({date_reg: -1}).limit(1);
|
||||
lastrec = await User.find({idapp}).sort({date_reg: -1}).limit(1).lean();
|
||||
if (!!lastrec) {
|
||||
return lastrec[0];
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user