Passport.js redirects to |successRedirect: '/profile'| but req.isAuthenticated() returns false

后端 未结 1 1356
一向
一向 2021-01-24 18:19

The following code is a section of an app developed by Node.js + Express + Passport.js. A valid user gets redirected to /profile url (successRedirect), however the

相关标签:
1条回答
  • 2021-01-24 18:51

    On each route where authentication is needed you should apply passport.authenticate middleware i.e :

    app.get('/profile', passport.authenticate('local'), (req, res) => {
      console.log(req.user);
      console.log(req.isAuthenticated());
    }
    

    see Passport documentation

    0 讨论(0)
提交回复
热议问题