Disabled debug Mongoose

Updated modules
fixed tests
This commit is contained in:
Paolo Arena
2021-09-22 01:13:41 +02:00
parent 10e9da805e
commit 396bfea289
73 changed files with 2831 additions and 2853 deletions

View File

@@ -1,5 +1,5 @@
const bcrypt = require('bcryptjs');
const mongoose = require('mongoose');
const mongoose = require('mongoose').set('debug', false)
const validator = require('validator');
const jwt = require('jsonwebtoken');
const _ = require('lodash');
@@ -500,19 +500,20 @@ UserSchema.statics.findByCredentials = function (idapp, username, password) {
UserSchema.statics.findByUsername = async function (idapp, username, alsoemail) {
const User = this;
const regexusername = new RegExp(["^", username, "$"].join(""), "i");
const myreg = ["^", username, "$"].join("")
let regexusername = new RegExp(myreg, "i");
return await User.findOne({
'idapp': idapp,
'username': regexusername,
return User.findOne({
idapp: idapp,
username: { $regex: regexusername },
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
}).then(async (ris) => {
}).then((ris) => {
if ((!ris) && (alsoemail)) {
regexemail = new RegExp(["^", username.toLowerCase(), "$"].join(""), "i");
return User.findOne({
'idapp': idapp,
'email': regexemail,
'email': { $regex: regexemail },
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
});
}
@@ -1448,7 +1449,7 @@ UserSchema.statics.isAdminByIdTeleg = async function (idapp, idtelegram) {
return await User.findOne({
idapp,
username: 'paoloarcnm',
username: 'paoloar77',
'profile.manage_telegram': true,
'profile.teleg_id': idtelegram
}, { 'profile.teleg_id': 1 })