0
I have a problem password update with Sequelize. The problem is when I try to update, the password that was previously encrypted by bcyrpt, loses the encryption. below the code where I try to do
hooks: {
beforeCreate: async usuario => {
const salt = await bcrypt.genSaltSync()
usuario.senha = bcrypt.hashSync(usuario.senha, salt)
},
beforeUpdate:async usuario=>{
if(usuario.senha){
const salt = await bcrypt.genSaltSync()
usuario.senha=bcrypt.hashSync(usuario.senha, salt)
}
}
The encryption on before client, is happening perfectly, but when updating the password it loses the encryption. I thank anyone who can help