i have a collection like this in mongodb
{
username:silver,
Email:[email protected],
password:silvester,
}
so to authenticate i will fetch data from database and then i will check given email is exist or not with if statement like this
app.post("/login",function(req,res){
var email=req.body['emailid'];
collection.find({email:[email protected]}).toArray(function(err,res)
{
if(res.length==0){
console.log("name is not exist");
}else{
if(res.email==email){
console.log("email is exist");
}else{
console.log("not exist");
}
}
});
});
so here how to use passport module for authentication.let me know it with sample code with configuration. i am using express3.x framework .so how to configure it also.