- Profile

- Bot Telegram
- fixed Chip multiselect
This commit is contained in:
Paolo Arena
2020-01-03 01:52:49 +01:00
parent 892eccb4fc
commit f359f8f723
13 changed files with 725 additions and 67 deletions

View File

@@ -16,36 +16,16 @@ const _ = require('lodash');
const { ObjectID } = require('mongodb');
router.post('/', authenticate, async (req, res) => {
const idapp = req.body.idapp;
try {
const aportador_solidario = req.user.aportador_solidario;
const aportador_solidario = req.user.aportador_solidario;
// DATA: username, name, surname, email, intcode_cell, cell
const dashboard = {
aportador: {},
downline: []
};
// Data of my Aportador
dashboard.aportador = await User.getUserShortDataByUsername(idapp, aportador_solidario);
// Data of my Downline
dashboard.downline = await User.getDownlineByUsername(idapp, req.user.username);
for (let index = 0; index < dashboard.downline.length; ++index) {
dashboard.downline[index].downline = await User.getDownlineByUsername(idapp, dashboard.downline[index].username);
}
// Extract all the todos of the userId only
// tools.mylog('dashboard', dashboard);
const dashboard = User.getDashboard(idapp, aportador_solidario, req.user.username);
if (dashboard)
res.send({ dashboard });
} catch (e) {
console.error(e);
else
res.status(400).send(e);
}
});

View File

@@ -27,6 +27,7 @@ const { Operator } = require('../models/operator');
const { Where } = require('../models/where');
const { MyEvent } = require('../models/myevent');
const { Contribtype } = require('../models/contribtype');
const { PaymentType } = require('../models/paymenttype');
const { Discipline } = require('../models/discipline');
const { Newstosent } = require('../models/newstosent');
const { MyPage } = require('../models/mypage');
@@ -161,6 +162,8 @@ function getTableByTableName(tablename) {
mytable = MyEvent;
else if (tablename === 'contribtype')
mytable = Contribtype;
else if (tablename === 'paymenttypes')
mytable = PaymentType;
else if (tablename === 'disciplines')
mytable = Discipline;
else if (tablename === 'newstosent')
@@ -244,7 +247,7 @@ router.patch('/chval', authenticate, (req, res) => {
const mytable = getTableByTableName(mydata.table);
const fieldsvalue = mydata.fieldsvalue;
// tools.mylogshow('PATCH CHVAL: ', id, fieldsvalue);
tools.mylogshow('PATCH CHVAL: ', id, fieldsvalue);
// If I change my record...
if ((!User.isAdmin(req.user) && !User.isManager(req.user)) && !(req.user._id.toString() === id)) {
@@ -373,6 +376,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
const operators = Operator.findAllIdApp(idapp);
const wheres = Where.findAllIdApp(idapp);
const contribtype = Contribtype.findAllIdApp(idapp);
const paymenttype = PaymentType.findAllIdApp(idapp);
const disciplines = Discipline.findAllIdApp(idapp);
const settings = Settings.findAllIdApp(idapp, false);
@@ -386,7 +390,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
newstosent = Newstosent.findAllIdApp(idapp);
}
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery])
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype])
.then((arrdata) => {
// console.table(arrdata);
const myuser = req.user;
@@ -407,6 +411,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
mailinglist: arrdata[9],
mypage: arrdata[10],
gallery: arrdata[11],
paymenttypes: arrdata[12],
myuser,
});
})

View File

@@ -147,9 +147,9 @@ router.post('/login', (req, res) => {
var user = new User(body);
// const subs = _.pick(req.body, ['subs']);
tools.mylog("LOGIN: username: " + user.username + " pwd = " + user.password);
// tools.mylog("LOGIN: username: " + user.username + " pwd = " + user.password);
tools.mylog("user REC:", user);
// tools.mylog("user REC:", user);
if (body.keyappid !== process.env.KEY_APP_ID)
return res.status(400).send();
@@ -180,7 +180,7 @@ router.post('/login', (req, res) => {
// }
// tools.mylog("user.verified_email:" + user.verified_email);
tools.mylog("usertosend.userId", usertosend.userId);
// tools.mylog("usertosend.userId", usertosend.userId);
return { usertosend, token }
@@ -198,7 +198,7 @@ router.post('/login', (req, res) => {
return { usertosend: myris.usertosend, token: myris.token, subsExistonDb: false }
})
}).then(myris => {
console.log('res', myris.token, myris.usertosend);
// console.log('res', myris.token, myris.usertosend);
// SEND TOKEN AND CODE RESULT
res.header('x-auth', myris.token).send({