fix Registrazione data
fix linkref fix controllo login
This commit is contained in:
@@ -3,6 +3,9 @@ const router = express.Router(),
|
||||
fs = require('fs'),
|
||||
path = require('path');
|
||||
|
||||
const jwt = require('jsonwebtoken');
|
||||
|
||||
const sendemail = require('../sendemail');
|
||||
|
||||
const { authenticate, authenticate_noerror } = require('../middleware/authenticate');
|
||||
|
||||
@@ -51,7 +54,7 @@ router.post(process.env.LINKVERIF_REG, (req, res) => {
|
||||
const body = _.pick(req.body, ['idapp', 'idlink']);
|
||||
const idapp = body.idapp;
|
||||
const idlink = body.idlink;
|
||||
console.log("LINKVERIF_REG POST " + process.env.LINKVERIF_REG + " idapp= " + idapp + " idlink = " + idlink);
|
||||
// console.log("LINKVERIF_REG POST " + process.env.LINKVERIF_REG + " idapp= " + idapp + " idlink = " + idlink);
|
||||
|
||||
// Cerco l'idlink se è ancora da Verificare
|
||||
|
||||
@@ -60,17 +63,18 @@ router.post(process.env.LINKVERIF_REG, (req, res) => {
|
||||
//console.log("NON TROVATO!");
|
||||
return res.status(404).send();
|
||||
} else {
|
||||
console.log('user', user);
|
||||
if (user.verified_email) {
|
||||
res.send({
|
||||
code: server_constants.RIS_CODE_EMAIL_ALREADY_VERIFIED,
|
||||
msg: res.__("L'Email è già stata Verificata.")
|
||||
msg: tools.getres__("L'Email è già stata Verificata", res)
|
||||
});
|
||||
} else {
|
||||
user.verified_email = true;
|
||||
user.lasttimeonline = new Date();
|
||||
user.save().then(() => {
|
||||
//console.log("TROVATOOOOOO!");
|
||||
res.send({ code: server_constants.RIS_CODE_EMAIL_VERIFIED, msg: res.__('Email Verificata!') });
|
||||
res.send({ code: server_constants.RIS_CODE_EMAIL_VERIFIED, msg: tools.getres__('EMAIL_VERIF', res) });
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -91,14 +95,14 @@ router.post(process.env.LINK_REQUEST_NEWPASSWORD, (req, res) => {
|
||||
|
||||
User.findByEmail(idapp, email).then((user) => {
|
||||
if (!user) {
|
||||
return res.status(404).send();
|
||||
return res.status(200).send({ code: server_constants.RIS_CODE_EMAIL_NOT_EXIST, msg: '' });
|
||||
} else {
|
||||
// Creo il tokenforgot
|
||||
user.tokenforgot = jwt.sign(user._id.toHexString(), process.env.SIGNCODE).toString();
|
||||
user.date_tokenforgot = new Date();
|
||||
user.lasttimeonline = new Date();
|
||||
user.save().then(async () => {
|
||||
await sendemail.sendEmail_RequestNewPassword(res.locale, user.email, user.idapp, user.tokenforgot);
|
||||
await sendemail.sendEmail_RequestNewPassword(res.locale, user, user.email, user.idapp, user.tokenforgot);
|
||||
res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
|
||||
});
|
||||
}
|
||||
@@ -426,12 +430,18 @@ 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, paymenttype])
|
||||
let calcstat = null;
|
||||
if (req.user)
|
||||
calcstat = User.calculateStat(idapp, req.user.username);
|
||||
|
||||
|
||||
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat])
|
||||
.then((arrdata) => {
|
||||
// console.table(arrdata);
|
||||
const myuser = req.user;
|
||||
if (myuser) {
|
||||
myuser.password = '';
|
||||
myuser._doc.calcstat = arrdata[13];
|
||||
}
|
||||
|
||||
res.send({
|
||||
|
||||
Reference in New Issue
Block a user