0 points

For Model password encrypting


dashboard

Sat Aug 22 2020 23:06:10 GMT+0000 (UTC)

Posted by @brainyworld #nodejs #javascript

userSchema.pre('save', async function(next){
    if (!this.isModified('password')) return next()
    this.password = await bcrypt.hash(this.password, 8)

    next()
})
content_copy Copy