fix(User): use beforeSave hook
This commit is contained in:
parent
edcd369037
commit
0b79d48d21
|
@ -11,7 +11,7 @@ class User extends Model {
|
||||||
* A hook to hash the user password before saving
|
* A hook to hash the user password before saving
|
||||||
* it to the database.
|
* it to the database.
|
||||||
*/
|
*/
|
||||||
this.addHook('beforeCreate', async (userInstance) => {
|
this.addHook('beforeSave', async (userInstance) => {
|
||||||
if (userInstance.dirty.password) {
|
if (userInstance.dirty.password) {
|
||||||
userInstance.password = await Hash.make(userInstance.password)
|
userInstance.password = await Hash.make(userInstance.password)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user