Skip to content

Node.js based forum software built for the modern web

closes #6318

Barış Soner Uşaklıf2dcbcd71020
diff --git a/src/user/email.js b/src/user/email.js
index 9c61211d9a..598536ad29 100644
--- a/src/user/email.js
+++ b/src/user/email.js
@@ -126,14 +126,24 @@ UserEmail.sendValidationEmail = function (uid, options, callback) {
};
UserEmail.confirm = function (code, callback) {
+ var confirmObj;
async.waterfall([
function (next) {
db.getObject('confirm:' + code, next);
},
- function (confirmObj, next) {
+ function (_confirmObj, next) {
+ confirmObj = _confirmObj;
if (!confirmObj || !confirmObj.uid || !confirmObj.email) {
return next(new Error('[[error:invalid-data]]'));
}
+
+ user.getUserField(confirmObj.uid, 'email', next);
+ },
+ function (currentEmail, next) {
+ if (!currentEmail || currentEmail.toLowerCase() !== confirmObj.email) {
+ return next(new Error('[[error:invalid-email]]'));
+ }
+
async.series([
async.apply(user.setUserField, confirmObj.uid, 'email:confirmed', 1),
async.apply(db.delete, 'confirm:' + code),