i have this line of code,i just want to know if it’s good practice to hash the password with the pre-save middleware like code below.? i mean is there is a securty issue about this or put something in the .env file
UserSchema.pre("save", async function (next) {
try {
const hashedhPassword = await bcrypt.hash(this.password, 10);
this.password = hashedhPassword;
} catch (err: any) {
next(err);
}
});