I am using passport-local strategy of passport for authentication. In my express server, I am getting a register post request and I should save password to db for a new user
Why should we go for hashing algorithm, when passport already provided it for us? I mean we just need to plugin the passport-local-mongoose to our user schema like: UserSchema.plugin(passportLocalMongoose)
and then, inside the register route we just tell the passportLocalMongoose
to do the hashing for us by using:
User.register(new User({username:req.body.username}), req.body.password,function(err,newUser)
{
if(err){
something
}else{
something
}
)
By doing above we don't need to take care of hashing and it will be done for us. Please correct me if I am wrong or got your question wrong.