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

@ -39,16 +39,11 @@ Controllers.errors = require('./errors');
Controllers.composer = require('./composer'); Controllers.composer = require('./composer');
Controllers.reset = function (req, res, next) { Controllers.reset = function (req, res, next) {
if (req.params.code) { const renderReset = function (code, valid) {
async.waterfall([
function (next) {
user.reset.validate(req.params.code, next);
},
function (valid) {
res.render('reset_code', { res.render('reset_code', {
valid: valid, valid: valid,
displayExpiryNotice: req.session.passwordExpired, displayExpiryNotice: req.session.passwordExpired,
code: req.params.code, code: code,
minimumPasswordLength: parseInt(meta.config.minimumPasswordLength, 10), minimumPasswordLength: parseInt(meta.config.minimumPasswordLength, 10),
minimumPasswordStrength: parseInt(meta.config.minimumPasswordStrength, 10), minimumPasswordStrength: parseInt(meta.config.minimumPasswordStrength, 10),
breadcrumbs: helpers.buildBreadcrumbs([ breadcrumbs: helpers.buildBreadcrumbs([
@ -63,8 +58,22 @@ Controllers.reset = function (req, res, next) {
title: '[[pages:reset]]', title: '[[pages:reset]]',
}); });
delete req.session.passwordExpired; delete req.session.passwordExpired;
}, };
], next);
if (req.params.code) {
// 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 { } else {
res.render('reset', { res.render('reset', {
code: null, code: null,

Loading…
Cancel
Save