From c19c0d088036b29282838dda2f47776f2ba0e339 Mon Sep 17 00:00:00 2001 From: Stephen Afam-Osemene Date: Tue, 24 Oct 2017 07:18:18 +0100 Subject: [PATCH] fix(hook): use beforeSave over beforeCreate Changed the hook from `beforeCreate` to `beforeSave` With `beforeCreate` the password will not be hashed if it is changed later --- 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 190c359..53ec9a8 100644 --- a/app/Models/User.js +++ b/app/Models/User.js @@ -13,7 +13,7 @@ class User extends Model { * Look at `app/Models/Hooks/User.js` file to * check the hashPassword method */ - this.addHook('beforeCreate', 'User.hashPassword') + this.addHook('beforeSave', 'User.hashPassword') } /**