fix(User): use beforeSave hook

This commit is contained in:
Romain Lanz
2018-06-10 22:33:30 +02:00
committed by GitHub
parent edcd369037
commit 0b79d48d21

View File

@@ -11,7 +11,7 @@ class User extends Model {
* A hook to hash the user password before saving
* it to the database.
*/
this.addHook('beforeCreate', async (userInstance) => {
this.addHook('beforeSave', async (userInstance) => {
if (userInstance.dirty.password) {
userInstance.password = await Hash.make(userInstance.password)
}