From 24bbf8fe00f0acb24bbdd1cf135ebb0118483736 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Thu, 10 Aug 2017 16:48:51 -0400 Subject: [PATCH] closes #5869 --- src/user/reset.js | 4 +++- test/user.js | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/user/reset.js b/src/user/reset.js index 438d629225..abe45a6031 100644 --- a/src/user/reset.js +++ b/src/user/reset.js @@ -120,12 +120,14 @@ UserReset.commit = function (code, password, callback) { }, function (hash, next) { async.parallel([ - async.apply(user.setUserField, uid, 'password', hash), + async.apply(user.setUserFields, uid, { password: hash, 'email:confirmed': 1 }), async.apply(db.deleteObjectField, 'reset:uid', code), async.apply(db.sortedSetRemove, 'reset:issueDate', code), async.apply(db.sortedSetRemove, 'reset:issueDate:uid', uid), async.apply(user.reset.updateExpiry, uid), async.apply(user.auth.resetLockout, uid), + async.apply(db.delete, 'uid:' + uid + ':confirm:email:sent'), + async.apply(db.sortedSetRemove, 'users:notvalidated', uid), ], next); }, ], callback); diff --git a/test/user.js b/test/user.js index 9b747e27b7..a5f92a1744 100644 --- a/test/user.js +++ b/test/user.js @@ -446,15 +446,16 @@ describe('User', function () { }); }); - it('.commit() should update the user\'s password', function (done) { + it('.commit() should update the user\'s password and confirm their email', function (done) { User.reset.commit(code, 'newpassword', function (err) { assert.ifError(err); - db.getObjectField('user:' + uid, 'password', function (err, newPassword) { + db.getObject('user:' + uid, function (err, userData) { assert.ifError(err); - Password.compare('newpassword', newPassword, function (err, match) { + Password.compare('newpassword', userData.password, function (err, match) { assert.ifError(err); assert(match); + assert.equal(parseInt(userData['email:confirmed'], 10), 1); done(); }); });