【发布时间】:2016-04-16 08:32:33
【问题描述】:
我正在编写一个“todolist”网络应用程序并使用 passport-facebook 进行第三方身份验证。这是我使用的代码:
passport.use(new FacebookStrategy({
clientID: '566950043453498',
clientSecret: '555022a61da40afc8ead59c6c26306ed',
callbackURL: 'http://www.localhost:3000/auth/facebook/Todolistpage.html'
},
function(accessToken, refreshToken, profile, done) {
console.log("hello " + profile.displayName);
done(null);
}
));
//Authentication
app.get('/auth/facebook', passport.authenticate('facebook'));
app.get('/auth/facebook/Todolistpage.html',
passport.authenticate('facebook', { successRedirect:'/auth/facebook/Todolistpage.html',
failureRedirect: '/login' }));
用户点击以下内容:
<a href="/auth/facebook">Login with Facebook</a>
我成功使用 facebook 登录,但我被重定向到代码的 failureRedirect 部分中指定的路径。它是怎么做到的?如果成功登录 facebook,我如何让它转到 successRedirect 中指定的路径?
【问题讨论】:
标签: javascript html node.js passport-facebook