Richiesta Cambio Password: ti manda il codice a 6 cifre e poterlo inserire sulla APP.
This commit is contained in:
@@ -135,26 +135,34 @@ router.post(process.env.LINKVERIF_REG, (req, res) => {
|
||||
|
||||
// Faccio richiesta di una Nuova Password
|
||||
router.post(process.env.LINK_REQUEST_NEWPASSWORD, async (req, res) => {
|
||||
const body = _.pick(req.body, ['idapp', 'email']);
|
||||
const idapp = body.idapp;
|
||||
const email = body.email.toLowerCase().trim();
|
||||
console.log(
|
||||
'POST ' + process.env.LINK_REQUEST_NEWPASSWORD + ' idapp= ' + idapp +
|
||||
' email = ' + email);
|
||||
|
||||
try {
|
||||
const ris = await User.createNewRequestPwd(idapp, email);
|
||||
if (ris) {
|
||||
res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
|
||||
const body = _.pick(req.body, ['idapp', 'email', 'codetocheck']);
|
||||
const idapp = body.idapp;
|
||||
const email = body.email.toLowerCase().trim();
|
||||
const codetocheck = body.codetocheck ? body.codetocheck.trim() : '';
|
||||
|
||||
// Check if too many requests
|
||||
if (await User.tooManyReqPassword(idapp, email, true)) {
|
||||
console.log(process.env.LINK_REQUEST_NEWPASSWORD, 'TOO MANY REQUESTS !!! EXIT ', email);
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_ERR, msg: 'TOO MANY REQUESTS' });
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log(
|
||||
'POST ' + process.env.LINK_REQUEST_NEWPASSWORD + ' idapp= ' + idapp +
|
||||
' email = ' + email);
|
||||
|
||||
const reqpwd = await User.createNewRequestPwd(idapp, email, codetocheck);
|
||||
if (reqpwd && reqpwd.ris) {
|
||||
res.send({ code: server_constants.RIS_CODE_OK, msg: '', link: reqpwd.link });
|
||||
} else {
|
||||
tools.snooze(5000);
|
||||
return res.status(200).
|
||||
send({ code: server_constants.RIS_CODE_EMAIL_NOT_EXIST, msg: '' });
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(process.env.LINK_REQUEST_NEWPASSWORD, e.message);
|
||||
res.status(400).send();
|
||||
res.send({ code: server_constants.RIS_CODE_ERR, msg: e });
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_ERR, msg: e });
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user