tweaks and refactoring for #2774

v1.18.x
Julian Lam 10 years ago
parent 3202a52a61
commit 55262b399a

@ -25,6 +25,7 @@
"email-not-confirmed": "Your email has not been confirmed yet, please click here to confirm your email.",
"email-not-confirmed-chat": "You are unable to chat until your email is confirmed",
"no-email-to-confirm": "This forum requires email confirmation, please click here to enter an email",
"email-confirm-failed": "We could not confirm your email, please try again later.",
"username-too-short": "Username too short",
"username-too-long": "Username too long",

@ -25,7 +25,6 @@
"email-confirmed": "Email Confirmed",
"email-confirmed-message": "Thank you for validating your email. Your account is now fully activated.",
"email-confirm-error": "An error occurred...",
"email-confirm-error-message": "There was a problem validating your email address. Perhaps the code was invalid or has expired.",
"email-confirm-sent": "Confirmation email sent."
}

@ -119,9 +119,10 @@ Controllers.register = function(req, res, next) {
Controllers.confirmEmail = function(req, res, next) {
user.email.confirm(req.params.code, function (data) {
data.status = data.status === 'ok';
res.render('confirm', data);
user.email.confirm(req.params.code, function (err) {
res.render('confirm', {
error: err ? err.message : ''
});
});
};

@ -87,21 +87,18 @@ var async = require('async'),
UserEmail.confirm = function(code, callback) {
db.getObject('confirm:' + code, function(err, confirmObj) {
if (err) {
return callback({
status:'error'
});
return callback(new Error('[[error:parse-error]]'));
}
if (confirmObj && confirmObj.uid && confirmObj.email) {
user.setUserField(confirmObj.uid, 'email:confirmed', 1, function() {
callback({
status: 'ok'
});
async.series([
async.apply(user.setUserField, confirmObj.uid, 'email:confirmed', 1),
async.apply(db.delete, 'confirm:' + code)
], function(err) {
callback(err ? new Error('[[error:email-confirm-failed]]') : null);
});
} else {
callback({
status: 'not_ok'
});
callback(new Error('[[error:invalid-data]]'));
}
});
};

Loading…
Cancel
Save