jaredhanson/passport-facebook

The re authenticate not working

ericbian22 opened this issue · 6 comments

Here is my code

  passport.use(new FacebookStrategy({
          clientID: process.env.FACEBOOK_APP_ID,
          clientSecret: process.env.FACEBOOK_APP_SECRET,
          callbackURL: "http://localhost:3000/auth/facebook/Welcome",
          profileFields: ["id", "email"],
          authType: 'reauthenticate'
      },
      function (accessToken, refreshToken, profile, cb) {
          User.findOrCreate({ username: profile.id },{provider: "facebook",email: profile._json.email},function (err, user) {
              return cb(err, user);
            }
          );
      }
  ));
  

Later I used

app.get("/Logout",function(req,res){
  req.session.destroy((err) => {
    req.logout()
    res.redirect("/");
  });
});

But when I log out, and it logs in with the same account without authentication, so how do I fix this issue?

Nia23 commented

Hello @ericbian22 did you end up finding a solution to this? :)

This worked for me #246

This worked for me #246

Hi, I enabled the force re-authenticate option in the facebook developer console but it is doing the same thing

Same problem here 😭.

Here is my code

  passport.use(new FacebookStrategy({
          clientID: process.env.FACEBOOK_APP_ID,
          clientSecret: process.env.FACEBOOK_APP_SECRET,
          callbackURL: "http://localhost:3000/auth/facebook/Welcome",
          profileFields: ["id", "email"],
          authType: 'reauthenticate'
      },
      function (accessToken, refreshToken, profile, cb) {
          User.findOrCreate({ username: profile.id },{provider: "facebook",email: profile._json.email},function (err, user) {
              return cb(err, user);
            }
          );
      }
  ));
  

Later I used

app.get("/Logout",function(req,res){
  req.session.destroy((err) => {
    req.logout()
    res.redirect("/");
  });
});

But when I log out, and it logs in with the same account without authentication, so how do I fix this issue?

This following is enough to logout from your session.

app.get("/logout", function(req, res){
  req.logout();
  res.redirect("/");
});