Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Passport facebook注销不工作_Node.js_Facebook_Passwords - Fatal编程技术网

Node.js Passport facebook注销不工作

Node.js Passport facebook注销不工作,node.js,facebook,passwords,Node.js,Facebook,Passwords,我正在尝试实现passport Facebook,我在server.js中的代码如下所示 用户单击“通过facebook登录”时使用的路径 router.get('/auth/facebook', passport.authenticate('facebook',{ scope : 'email' }), function(req, res){ }); 成功登录后,它会重定向到success.html,作为注销按钮 router.get('/auth/f

我正在尝试实现passport Facebook,我在server.js中的代码如下所示 用户单击“通过facebook登录”时使用的路径

 router.get('/auth/facebook',
      passport.authenticate('facebook',{ scope : 'email' }),
      function(req, res){
      });
成功登录后,它会重定向到success.html,作为注销按钮

 router.get('/auth/facebook/callback',
      passport.authenticate('facebook', {
        successRedirect : '/success',
        failureRedirect: '/'
      }),
      function(req, res) {
        res.render('success.html');
      });
注销路线为

  router.get('/logout', function(req, res){
      req.logout();
      res.redirect('/');
    });
若我仍然点击注销按钮,我将被重定向到主页

router.get('/', function(req, res){
  res.render('auth.html');
});
auth.html

  <html>
        <head>
          <title>Node.js OAuth</title>
        </head>
        <body>
        <a href="/auth/facebook">Sign in with Facebook</a>
        </body>
        </html>




but after if i click the Sign in with Facebook link i will directly take to success.html page  and again i was never able to see the Facebook login page where we provide the credentials of the Facebook account 

Node.js OAuth
但是,如果我点击“使用Facebook登录”链接,我将直接进入success.html页面,再次,我无法看到我们提供Facebook帐户凭据的Facebook登录页面
*我试图从数据库中删除细节,但它仍然指向success.html *我尝试删除cookie以及新的浏览器实例
*运气不好,请告诉我可能出现的错误

您的页面被重定向到“success.html”,因为Facebook会记住登录凭据。除非您手动从Facebook注销,否则您的应用程序将始终重定向到“success.html”

这就是你可以从应用程序中注销Facebook的方法

在logout.html页面中:


以下代码进入控制器:

router.post('/logoutFromFacebook',函数(req,res){
reshttps://www.facebook.com/logout.php?next='+server.ip+'/logout&access_-token='+req.body['accessToken']);
});
路由器.get('/logout',函数(req,res){
请求注销();
res.redirect('/');
});
server.ip必须是运行应用程序的url。
例如:如果它在本地运行

如果远程运行

请参阅

将第一位更改为如下所示:

router.get('/auth/facebook',
  passport.authenticate('facebook', {
    scope: 'email',
    authType: 'reauthenticate',
    authNonce: 'foo123'
  })
);