3
我有這樣一個集合MongoDB中的MongoDB和認證和護照的node.js
{
username:silver,
Email:[email protected],
password:silvester,
}
所以要驗證我將獲取從數據庫中的數據,然後我會檢查指定的電子郵件是存在的或不符合if語句像這樣
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");
}
}
});
});
所以在這裏如何使用護照模塊進行身份驗證。我知道它帶有配置示例代碼。 我正在使用express3.x框架.so如何配置它也。
我應該寫像上面這樣app.post POST請求( '/登錄',函數(REQ內編碼,RES){passport.use(新LocalStrategy( { emailField:'email', passwordField:'passw', },})讓我知道它.. – silvesterprabu 2013-03-08 09:21:02
我不確定這是個好主意。另外,請不要忘記關於'passport.serializeUser'和'passport.deserializeUser'。 – msmirnov 2013-03-08 09:26:07
如何使用護照來驗證mongodb的數據 – silvesterprabu 2013-03-08 09:32:02