jaredhanson / passport-facebook

Facebook authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-facebook/?utm_source=github&utm_medium=referral&utm_campaign=passport-facebook&utm_content=about
MIT License
1.29k stars 446 forks source link

The re authenticate not working #277

Open ericbian22 opened 4 years ago

ericbian22 commented 4 years ago

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 4 years ago

farleyschaefer commented 3 years ago

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

farleyschaefer commented 3 years ago

This worked for me #246

ericbian22 commented 3 years ago

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

berlincho commented 3 years ago

Same problem here 😭.

babu0008 commented 3 years ago

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("/");
});