app.post("/register",function(req,res){
User.register({username: req.body.username},req.body.password,function(err,user){
if(err)
res.redirect("/register");
else
{
passport.authenticate("local")(req,res,function(){
res.redirect("/secrets")
});
}
});
});
Here, we are clearly using User.register for saving the data into the database. But when we use req.login, we nowhere specify which database to search in. So, how does passportJS know which database to search in. Here's an example:
app.post("/login", passport.authenticate("local"), function(req, res){
res.redirect("/secrets");
});
Here, how is the posted data being seached in the User model.