diff --git a/public/language/en_GB/error.json b/public/language/en_GB/error.json index b2f9a3b86b..6d64645c59 100644 --- a/public/language/en_GB/error.json +++ b/public/language/en_GB/error.json @@ -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", diff --git a/public/language/en_GB/notifications.json b/public/language/en_GB/notifications.json index 96aef60183..19de8e2c28 100644 --- a/public/language/en_GB/notifications.json +++ b/public/language/en_GB/notifications.json @@ -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." } diff --git a/src/controllers/index.js b/src/controllers/index.js index d8ddf81735..7f4afeb4dc 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -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 : '' + }); }); }; diff --git a/src/user/email.js b/src/user/email.js index 74b86c0cfe..e7f56ed21a 100644 --- a/src/user/email.js +++ b/src/user/email.js @@ -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]]')); } }); };