search

Home  >  Q&A  >  body text

html - 使用mongoose.createConnection连接数据库,当以post方式提交表单时,页面不跳转

PHPzPHPz2781 days ago598

reply all(5)I'll reply

  • ringa_lee

    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

    reply
    0
  • 黄舟

    黄舟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

    reply
    0
  • 巴扎黑

    巴扎黑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.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 16:38:32

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

    reply
    0
  • 黄舟

    黄舟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.

    reply
    0
  • Cancelreply