html - 使用mongoose.createConnection连接数据库,当以post方式提交表单时,页面不跳转
PHPz
PHPz 2017-04-17 16:36:32
0
5
626
PHPz
PHPz

学习是最好的投资!

reply all(5)
左手右手慢动作
if(err){
      req.session.regenerate(function(){
        req.session.msg = err;
        res.redirect('/login');
      });
    }

Add an else here to do a jump test

黄舟

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

巴扎黑

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.

Peter_Zhu

Your username and password do not match those of the database!

黄舟

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template