ringa_lee2017-04-17 16:38:32
if(err){
req.session.regenerate(function(){
req.session.msg = err;
res.redirect('/login');
});
}
Add an else here to do a jump test
黄舟2017-04-17 16:38:32
The jump logic is not implemented in these two places. Does it mean that the user does not exist or the password is wrong? You can try adding a jump.
if (!user){
err = 'User Not Found.';
}
...
else{
err = 'Authentication failed.';
}
soonfy
巴扎黑2017-04-17 16:38:32
What did you write at the front desk? Generally, ajax is used to request the server when logging in. At this time, the browser does not recognize the jump returned by you in the background. It needs to be processed separately, or the URL returned by the background is processed in the ajax callback method.
黄舟2017-04-17 16:38:32
The problem has been found because using mongoose.createConnection to connect to the database can only operate the database in the current js. Here I just looked up the data in the users table. In the routing, I also involved data query operations in other tables. There is nothing written there. mongoose.createConnection connection operation library operation.