Merge pull request #3072 from strongloop/backport/email-verified-fix
Fix false emailVerified on user model update
This commit is contained in:
commit
0caee53f6b
|
@ -845,7 +845,7 @@ module.exports = function(User) {
|
||||||
if (emailChanged && ctx.Model.settings.emailVerificationRequired) {
|
if (emailChanged && ctx.Model.settings.emailVerificationRequired) {
|
||||||
ctx.instance.emailVerified = false;
|
ctx.instance.emailVerified = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (ctx.data.email) {
|
||||||
emailChanged = ctx.hookState.originalUserData.some(function(data) {
|
emailChanged = ctx.hookState.originalUserData.some(function(data) {
|
||||||
return data.email != ctx.data.email;
|
return data.email != ctx.data.email;
|
||||||
});
|
});
|
||||||
|
|
|
@ -2358,6 +2358,28 @@ describe('User', function() {
|
||||||
], done);
|
], 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) {
|
function createOriginalUser(done) {
|
||||||
var userData = {
|
var userData = {
|
||||||
email: 'original@example.com',
|
email: 'original@example.com',
|
||||||
|
|
Loading…
Reference in New Issue