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,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 ------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue