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

View file

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