Merge pull request #3053 from yumenohosi/fix/email-verified
Fix false emailVerified on user model update
This commit is contained in:
commit
f4b167698a
|
@ -858,7 +858,7 @@ module.exports = function(User) {
|
|||
if (emailChanged && ctx.Model.settings.emailVerificationRequired) {
|
||||
ctx.instance.emailVerified = false;
|
||||
}
|
||||
} else {
|
||||
} else if (ctx.data.email) {
|
||||
var emailChanged = ctx.hookState.originalUserData.some(function(data) {
|
||||
return data.email != ctx.data.email;
|
||||
});
|
||||
|
|
|
@ -2315,6 +2315,28 @@ describe('User', function() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should not set verification to false after something other than email is updated',
|
||||
function(done) {
|
||||
User.settings.emailVerificationRequired = true;
|
||||
async.series([
|
||||
function updateUser(next) {
|
||||
userInstance.updateAttribute('realm', 'test', function(err, info) {
|
||||
if (err) return next (err);
|
||||
assert.equal(info.realm, 'test');
|
||||
next();
|
||||
});
|
||||
},
|
||||
function findUser(next) {
|
||||
User.findById(userInstance.id, function(err, info) {
|
||||
if (err) return next (err);
|
||||
assert.equal(info.realm, 'test');
|
||||
assert.equal(info.emailVerified, true);
|
||||
next();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
function createOriginalUser(done) {
|
||||
var userData = {
|
||||
email: 'original@example.com',
|
||||
|
|
Loading…
Reference in New Issue