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

Loading…
Cancel
Save