S
S
SpideR-KOSS2018-08-30 07:56:42
JavaScript
SpideR-KOSS, 2018-08-30 07:56:42

Why doesn't the PassportJS code work?

Why the code does not work with off. site, slightly modified?

app.get("/login", function(req, res, next) {
  passport.authenticate("local", function(err, user, info) {
    if (err) {
      return next(err);
    }
    if (!user) {
      return res.render("login");
    }
    req.logIn(user, function(err) {
      if (err) {
        return next(err);
      }
      return res.redirect("/");
    });
  })(req, res, next);
});

On login, we check if the user is logged in. If not, we render the login page, if yes, we redirect to the main page.
Why does not it work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RidgeA, 2018-08-30
@RidgeA

wang that is not connected correctly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question