Iscrizione Conacreis e Arcadei
This commit is contained in:
@@ -39,6 +39,7 @@ const {MyEvent} = require('../models/myevent');
|
||||
const {Contribtype} = require('../models/contribtype');
|
||||
const {PaymentType} = require('../models/paymenttype');
|
||||
const {Discipline} = require('../models/discipline');
|
||||
const {MyElem} = require('../models/myelem');
|
||||
const {Skill} = require('../models/skill');
|
||||
const {Good} = require('../models/good');
|
||||
const {StatusSkill} = require('../models/statusSkill');
|
||||
|
||||
82
src/server/router/iscrittiArcadei_router.js
Executable file
82
src/server/router/iscrittiArcadei_router.js
Executable file
@@ -0,0 +1,82 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
const IscrittiArcadei = require('../models/iscrittiArcadei');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
const sendemail = require('../sendemail');
|
||||
|
||||
const { Settings } = require('../models/settings');
|
||||
|
||||
const tools = require('../tools/general');
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const server_constants = require('../tools/server_constants');
|
||||
|
||||
const telegrambot = require('../telegram/telegrambot');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
|
||||
|
||||
// POST /iscritti_arcadei
|
||||
router.post('/', async (req, res) => {
|
||||
tools.mylog("POST /iscritti_arcadei");
|
||||
const body = req.body;
|
||||
body.email = body.email.toLowerCase();
|
||||
|
||||
const iscritti = new IscrittiArcadei(body);
|
||||
iscritti.ipaddr = tools.getiPAddressUser(req);
|
||||
iscritti.lang = req.locale;
|
||||
|
||||
// tools.mylog("LANG PASSATO = " + iscritti.lang, "IDAPP", iscritti.idapp);
|
||||
|
||||
if (!tools.isAlphaNumeric(body.name)) {
|
||||
await tools.snooze(5000);
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_USERNAME_NOT_VALID, msg: '' });
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (tools.blockwords(body.username) || tools.blockwords(body.email) || tools.blockwords(body.name) || tools.blockwords(body.surname)) {
|
||||
// tools.writeIPToBan(iscritti.ipaddr + ': [' + iscritti.username + '] ' + iscritti.name + ' ' + iscritti.surname);
|
||||
await tools.snooze(5000);
|
||||
return res.status(404).send();
|
||||
}
|
||||
|
||||
iscritti.dateofreg = new Date();
|
||||
|
||||
// Controlla se anche l'ultimo record era dallo stesso IP:
|
||||
const lastrec = await IscrittiArcadei.getLastRec(body.idapp);
|
||||
if (!!lastrec) {
|
||||
if (process.env.LOCALE !== "1") {
|
||||
if (lastrec.ipaddr === iscritti.ipaddr) {
|
||||
// Se l'ha fatto troppo ravvicinato
|
||||
if (lastrec.date_reg) {
|
||||
let ris = tools.isdiffSecDateLess(lastrec.date_reg, 120);
|
||||
if (ris) {
|
||||
tools.writeIPToBan(iscritti.ipaddr + ': ' + tools.getNomeCognomeEUserNameByUser(iscritti));
|
||||
await tools.snooze(10000);
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_BANIP, msg: '' });
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return iscritti.save()
|
||||
.then(async () => {
|
||||
await sendemail.sendEmail_IscrizioneArcadei(iscritti.lang, iscritti.email, iscritti, iscritti.idapp);
|
||||
// }
|
||||
return res.status(200).send();
|
||||
}).catch((e) => {
|
||||
console.error(e.message);
|
||||
res.status(400).send(e);
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user