Lista Amici

Richieste di Fiducia
Accettati
Rifiutati
This commit is contained in:
paoloar77
2022-01-07 01:18:01 +01:00
parent 181af3c895
commit 3b6218d2ba
11 changed files with 1254 additions and 663 deletions

View File

@@ -17,4 +17,18 @@ router.get('/:idapp/:email', (req, res) => {
});
});
router.post('/ck', (req, res) => {
const idapp = req.body.idapp;
var email = req.body.email;
User.findByEmail(idapp, email).then((user) => {
if (!user) {
return res.status(404).send();
}
res.status(200).send();
}).catch((e) => {
res.status(400).send();
});
});
module.exports = router;

View File

@@ -455,7 +455,7 @@ router.post('/gettable', authenticate, (req, res) => {
return res.send(ris);
}).catch((e) => {
console.log(e.message);
console.log('gettable: ' + e.message);
res.status(400).send(e);
});
@@ -601,6 +601,13 @@ router.patch('/chval', authenticate, async (req, res) => {
}
if (mydata.table === shared_consts.TAB_SITES) {
if (shared_consts.SITES_KEY_TO_CRYPTED in fieldsvalue) {
fieldsvalue[shared_consts.SITES_KEY_TO_CRYPTED] = tools.cryptdata(fieldsvalue[shared_consts.SITES_KEY_TO_CRYPTED]);
}
}
await mytable.findByIdAndUpdate(id, {$set: fieldsvalue}).then(async (rec) => {
// tools.mylogshow(' REC TO MODIFY: ', rec);
if (!rec) {
@@ -1559,8 +1566,9 @@ function uploadFile(req, res, version) {
form.parse(req);
let dirmain = '/statics';
console.log('process.env.PROD', process.env.PROD);
if (version > 0) {
if (process.env.PROD === 1) {
if (process.env.PROD === '1') {
dirmain = '';
} else {
dirmain = '/public';

View File

@@ -107,6 +107,12 @@ router.post('/', async (req, res) => {
user.lasttimeonline = new Date();
user.date_reg = new Date();
user.aportador_iniziale = user.aportador_solidario;
if (!tools.getAskToVerifyReg(body.idapp)) {
// Se non devo chiedere di verificare all'Invitato, allora lo verifico direttamente
user.verified_by_aportador = true;
}
/* if (user.idapp === tools.AYNI) {
user.profile.paymenttypes = ['paypal'];
} */
@@ -319,7 +325,7 @@ router.patch('/:id', authenticate, (req, res) => {
});
});
router.post('/profile', (req, res) => {
router.post('/profile', authenticate, (req, res) => {
const username = req.body['username'];
idapp = req.body.idapp;
locale = req.body.locale;
@@ -470,6 +476,45 @@ router.post('/import_extralist', async (req, res) => {
res.send(ris);
});
router.post('/friends', authenticate, (req, res) => {
const username = req.user.username;
idapp = req.body.idapp;
locale = req.body.locale;
return User.getFriendsByUsername(idapp, username).then((ris) => {
res.send(ris);
}).catch((e) => {
tools.mylog('ERRORE IN Profile: ' + e.message);
res.status(400).send();
});
});
router.post('/friends/cmd', authenticate, (req, res) => {
const usernameLogged = req.user.username;
const idapp = req.body.idapp;
const locale = req.body.locale;
const usernameOrig = req.body.usernameOrig;
const usernameDest = req.body.usernameDest;
const cmd = req.body.cmd;
const value = req.body.value;
if (!User.isAdmin(req.user.perm) || !User.isManager(req.user.perm)) {
// If without permissions, exit
if (usernameOrig !== usernameLogged) {
return res.status(404).send({code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: ''});
}
}
return User.setFriendsCmd(idapp, usernameOrig, usernameDest, cmd, value).then((ris) => {
res.send(ris);
}).catch((e) => {
tools.mylog('ERRORE IN Friends/cmd: ' + e.message);
res.status(400).send();
});
});
async function eseguiDbOp(idapp, mydata, locale) {
let ris = await User.DbOp(idapp, mydata);