1
0
Fork 0

Don't hash user password once again on update

This commit is contained in:
Chocobozzz 2017-11-04 18:09:23 +01:00
parent 08535e56aa
commit 59557c4663
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 7 additions and 4 deletions

View File

@ -136,10 +136,13 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
}
function beforeCreateOrUpdate (user: UserInstance) {
return cryptPassword(user.password).then(hash => {
user.password = hash
return undefined
})
if (user.changed('password')) {
return cryptPassword(user.password)
.then(hash => {
user.password = hash
return undefined
})
}
}
// ------------------------------ METHODS ------------------------------