使用Passport登录后,将Messenger bot用户重定向到Messenger

时间:2016-12-27 11:02:10

标签: node.js bots facebook-messenger passport-facebook passport.js

我有一个像这样的简单护照路由器

app.get('/auth/facebook', 
    passport.authenticate('facebook',{ scope: ['user_likes', 'user_location'],
    session: true
    })
    );

app.get('/auth/facebook/callback', 
  passport.authenticate('facebook'), (req, res) => {
    var messengerApp = 'https://m.me/appUserName';
    res.redirect(messengerApp || '/');
});

app.get('/', function( req, res ){
  res.header( 'Content-Type', 'text/html' );
  res.status(200).send('<html><body><a href="/auth/facebook">Login with Facebook</a></body></html>');
});

此代码会将用户重定向到Messenger,但会跳过Login部分。如果我擦除messengerApp ||,代码将重定向到登录按钮,但是一旦单击该按钮,用户将被重新切换到相同的登录按钮页面“/”。 如何将用户重定向到他在Bot on Messenger上的对话?

0 个答案:

没有答案