From ba18e2d7121979f0c4e0b9e49ea142afe689c027 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 21 May 2018 17:36:32 -0400 Subject: [PATCH] feat(hook): Verify status before hashing To prevent double-hashing on udpate --- app/Models/User.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/User.js b/app/Models/User.js index 265968c..1740431 100644 --- a/app/Models/User.js +++ b/app/Models/User.js @@ -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) } })