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

@@ -33,7 +33,7 @@ const Product = require('../models/product')
const Variant = require('../models/variant')
const TypedError = require('../modules/ErrorHandler')
const mongoose = require('mongoose');
const mongoose = require('mongoose').set('debug', false)
const Subscription = mongoose.model('subscribers');
function existSubScribe(userId, access, browser) {
@@ -55,7 +55,18 @@ function getMobileComplete(user) {
return str
}
router.post('/test1', async (req, res) => {
const user = await User.findOne({
idapp: 1,
username: 'paoloar77',
});
await sendemail.sendEmail_Registration(user.lang, user.email, user,
user.idapp, user.linkreg);
})
// POST /users
router.post('/', async (req, res) => {
@@ -68,7 +79,7 @@ router.post('/', async (req, res) => {
// tools.mylog("LANG PASSATO = " + user.lang, "IDAPP", user.idapp);
if (!tools.isAlphaNumeric(body.username)) {
if (!tools.isAlphaNumeric(body.username) || body.email.length < 6 || body.username.length < 6 || body.password.length < 6) {
await tools.snooze(5000);
res.status(400).send({ code: server_constants.RIS_CODE_USERNAME_NOT_VALID, msg: '' });
return 1;
@@ -166,35 +177,6 @@ router.post('/', async (req, res) => {
// nomeaportador_corretto = recextra.aportador_solidario_originale_name_surname;
// }
const numero = user.name.slice(-1);
if ((numero === '2') || (numero === '3') || (numero === '4') || (numero === '5') || (numero === '6')) {
recorig = await User.findByCellAndNameSurname(user.idapp, user.profile.cell, user.name.slice(0, -1), user.surname);
if (!!recorig) {
user.profile.teleg_id = recorig.profile.teleg_id;
// user.profile.saw_zoom_presentation = recorig.profile.saw_zoom_presentation;
user.profile.saw_and_accepted = recorig.profile.saw_and_accepted;
// user.profile.my_dream = recorig.profile.my_dream;
user.profile.email_paypal = recorig.profile.email_paypal;
user.profile.payeer_id = recorig.profile.payeer_id;
user.profile.advcash_id = recorig.profile.advcash_id;
user.profile.revolut = recorig.profile.revolut;
user.profile.link_payment = recorig.profile.link_payment;
user.profile.note_payment = recorig.profile.note_payment;
user.profile.paymenttypes = recorig.profile.paymenttypes;
user.profile.qualified = recorig.profile.qualified;
let msgseconda = '!!! REGISTRATA ';
if (numero === '2')
msgseconda += 'SECONDA';
else if (numero === '3')
msgseconda += 'TERZA';
else if (numero === '4')
msgseconda += 'QUARTA';
msgseconda += ' UTENZA di ' + recorig.name + ' ' + recorig.surname + ' (' + recorig.username + ') : ' + user.name + ' ' + user.surname + ' (' + user.username + ') ';
await telegrambot.sendMsgTelegramToTheManagers(user.idapp, msgseconda);
}
}
namesurname_aportador_reg = await User.getNameSurnameByUsername(user.idapp, user.aportador_solidario);
if (recextra && namesurname_aportador_reg !== '' && namesurname_aportador_reg !== nomeaportador_corretto) {
@@ -242,16 +224,13 @@ router.post('/', async (req, res) => {
user.perm = shared_consts.Permissions.Manager + shared_consts.Permissions.Admin;
}
// const useraportador = await ExtraList.findByIndOrder(user.idapp, user.aportador_solidario_ind_order);
// if (useraportador)
// user.aportador_solidario = useraportador.username;
}
}
return await user.save()
return user.save()
.then(async () => {
return await User.findByUsername(user.idapp, user.username, false)
return User.findByUsername(user.idapp, user.username, false)
.then((usertrovato) => {
// tools.mylog("TROVATO USERNAME ? ", user.username, usertrovato);
@@ -304,9 +283,10 @@ router.get('/:idapp/:username', async (req, res) => {
if (!user) {
return res.status(404).send();
}
res.status(200).send();
// console.log('TROVATO!')
return res.status(200).send();
}).catch((e) => {
res.status(400).send();
return res.status(400).send();
});
});