v1.18.x
Julian Lam 7 years ago
parent 7d7a490550
commit f09b1acfb7

@ -39,32 +39,41 @@ Controllers.errors = require('./errors');
Controllers.composer = require('./composer');
Controllers.reset = function (req, res, next) {
const renderReset = function (code, valid) {
res.render('reset_code', {
valid: valid,
displayExpiryNotice: req.session.passwordExpired,
code: code,
minimumPasswordLength: parseInt(meta.config.minimumPasswordLength, 10),
minimumPasswordStrength: parseInt(meta.config.minimumPasswordStrength, 10),
breadcrumbs: helpers.buildBreadcrumbs([
{
text: '[[reset_password:reset_password]]',
url: '/reset',
},
{
text: '[[reset_password:update_password]]',
},
]),
title: '[[pages:reset]]',
});
delete req.session.passwordExpired;
};
if (req.params.code) {
async.waterfall([
function (next) {
user.reset.validate(req.params.code, next);
},
function (valid) {
res.render('reset_code', {
valid: valid,
displayExpiryNotice: req.session.passwordExpired,
code: req.params.code,
minimumPasswordLength: parseInt(meta.config.minimumPasswordLength, 10),
minimumPasswordStrength: parseInt(meta.config.minimumPasswordStrength, 10),
breadcrumbs: helpers.buildBreadcrumbs([
{
text: '[[reset_password:reset_password]]',
url: '/reset',
},
{
text: '[[reset_password:update_password]]',
},
]),
title: '[[pages:reset]]',
});
delete req.session.passwordExpired;
},
], next);
// Save to session and redirect
req.session.reset_code = req.params.code;
res.redirect(nconf.get('relative_path') + '/reset');
} else if (req.session.reset_code) {
// Validate and save to local variable before removing from session
user.reset.validate(req.session.reset_code, function (err, valid) {
if (err) {
return next(err);
}
renderReset(req.session.reset_code, valid);
delete req.session.reset_code;
});
} else {
res.render('reset', {
code: null,

Loading…
Cancel
Save