Saturday 11 March 2017

Error in Login Route

I have a system set up to let user's update their password via email. Once they have updated the password for some reason passport with not authenticate the new password. They can only login with the old old. However looking in the database the password has clearly been updated. I believe there is an error in my login functionality.

router.post('/login', function(req, res, next) {
      passport.authenticate('local', function(err, user, info) {
        if (err) return next(err)
        console.log('this' + err)
        if (!user) {
          return res.redirect('/login')
          console.log('there was no user')
        }
        req.logIn(user, function(err) {
            console.log('logging in')
          if (err) return next(err);
          return res.redirect('/');
        });
      })(req, res, next);
    });



via AndrewLeonardi

No comments:

Post a Comment