我已经使用护照本地会话创建并登录了会话,但是将其部署到服务器上后,出现连接超时错误,这是我的功能代码:-
if(req.method=="POST")
{
passport.authenticate('local',{successRedirect:'/addjob',failureRedirect:'/adminlogin',failureFlash:false}),
function(req,res)
{
res.redirect('/addjob');
}
}
这是我的护照配置:-
passport.use(new LocalStratergy(function(User_id,password,done){
let query={user_id:user_id};
User.findOne(query,function(err,user){
if(err)throw err;
if(!user){
return done(null,false,{message:'User Not Found'});
}
bcrypt.compare(password,user.password,function(err,isMatch){
if(err)throw err;
if(isMatch)
{
return done(null,user);
}
else
{
return done(null,false,{message:'Wrong password'});
}
});
});
}));
这是捕获数据的形式:-
<form method="POST" action="/login">
<div class="form-group">
<input type="text" class="form-control" id="user_id" placeholder="User Id">
</div>
<div class="form-group">
<input type="password" class="form-control" id="password" placeholder="Passowrd">
</div>
<div class="form-group text-center">
<button type="sumbit" class="btn btn-primary"> Login</button>
<button type="sumbit" class="btn btn-primary"> Register</button>
</div>
</form>
</div>
谁能告诉我iam出了什么问题,我该如何纠正?