feat(hook): Verify status before hashing

To prevent double-hashing on udpate
This commit is contained in:
Roman 2018-05-21 17:36:32 -04:00 committed by Harminder
parent 4405040d99
commit ba18e2d712

View File

@ -12,7 +12,7 @@ class User extends Model {
* it to the database.
*/
this.addHook('beforeCreate', async (userInstance) => {
if (userInstance.password) {
if (userInstance.dirty.password) {
userInstance.password = await Hash.make(userInstance.password)
}
})