- Downline User

- Not registered if already exists.
- Forgot Password
This commit is contained in:
Paolo Arena
2020-01-30 01:19:25 +01:00
parent 25ad3e91c2
commit 512a8c14e2
12 changed files with 551 additions and 44 deletions

View File

@@ -62,11 +62,11 @@ router.post('/', async (req, res) => {
user.verified_email = true;
}
if (user.profile.intcode_cell) {
if (user.profile.cell.substring(0, user.profile.intcode_cell.length) === user.profile.intcode_cell) {
user.profile.cell = user.profile.cell.substring(user.profile.intcode_cell.length)
}
}
// if (user.profile.intcode_cell) {
// if (user.profile.cell.substring(0, user.profile.intcode_cell.length) === user.profile.intcode_cell) {
// user.profile.cell = user.profile.cell.substring(user.profile.intcode_cell.length)
// }
// }
let exit;
// Check if already esist email or username
@@ -93,9 +93,18 @@ router.post('/', async (req, res) => {
if (exit === 1)
return;
let recuser = null;
recuser = await User.findByCellAndNameSurname(user.idapp, user.profile.cell, user.name, user.surname);
if (recuser) {
// User already registered!
res.status(400).send({ code: server_constants.RIS_CODE_USER_ALREADY_EXIST, msg: '' });
return 1;
}
let recextra = null;
recextra = await ExtraList.findByCellAndNameSurname(user.idapp, getMobileComplete(user), user.name, user.surname);
recextra = await ExtraList.findByCellAndNameSurname(user.idapp, user.profile.cell, user.name, user.surname);
let nomeaportador_corretto = "";
if (recextra) {
nomeaportador_corretto = recextra.aportador_solidario_name_surname;
@@ -103,6 +112,9 @@ router.post('/', async (req, res) => {
nomeaportador_corretto = recextra.aportador_solidario_originale_name_surname;
}
const lastuser = await User.getLastUser(user.idapp);
const lastextra = await ExtraList.getLastUser(user.idapp);
let lastindorder = 0;
@@ -139,10 +151,10 @@ router.post('/', async (req, res) => {
if (already_registered) {
// Check in the extraList if is present!
if (!recextra) {
console.log('Utente non trovato; ', user);
const msg = 'Utente non trovato: ' + user.name + ' ' + user.surname + ' ' + user.profile.nationality + ' ' + user.profile.intcode_cell + user.profile.cell + ' email: ' + user.email + ' username: ' + user.username;
const msg = 'Utente non trovato: ' + user.name + ' ' + user.surname + ' ' + user.profile.nationality + ' ' + user.profile.cell + ' email: ' + user.email + ' username: ' + user.username;
console.log('Utente non trovato; ', msg);
telegrambot.sendMsgTelegramToTheManagers(user.idapp, msg);
res.status(400).send({ code: server_constants.RIS_CODE_USER_EXTRALIST_NOTFOUND, msg: '' });
res.status(400).send({ code: server_constants.RIS_CODE_USER_EXTRALIST_NOTFOUND, msg: 'Controlla se il numero ' + user.profile.cell + ' è corretto.' });
return 1;
} else {
user.ind_order = recextra.ind_order;
@@ -267,11 +279,12 @@ router.post('/login', (req, res) => {
let resalreadysent = false;
User.findByCredentials(user.idapp, user.username, user.password)
.then((user) => {
.then(async (user) => {
// tools.mylog("CREDENZIALI ! ");
if (!user) {
tools.mylogshow("Errore LOGIN ! Username o password Errati: ", body.username, body.password);
await tools.snooze(3000);
const msg = "Tentativo di Login ERRATO [" + body.username + ' , ' + body.password + ']\n' + '[IP: ' + tools.getiPAddressUser(req) + ']';
tools.mylogshow(msg);
telegrambot.sendMsgTelegramToTheManagers(body.idapp, msg);
res.status(404).send({ code: server_constants.RIS_CODE_LOGIN_ERR });
}
@@ -363,5 +376,17 @@ router.post('/import_extralist', async (req, res) => {
res.send(ris);
});
router.post('/dbop', async (req, res) => {
const mydata = req.body.mydata;
idapp = req.body.idapp;
locale = req.body.locale;
const ris = await User.DbOp(idapp, mydata);
console.log('ris', ris);
res.send(ris);
});
module.exports = router;