Don't hash user password once again on update
This commit is contained in:
parent
08535e56aa
commit
59557c4663
1 changed files with 7 additions and 4 deletions
|
@ -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 ------------------------------
|
||||
|
|
Loading…
Reference in a new issue