我使用Passport for NodeJS进行身份验证。我已经成功整合了它。如果用户已经在他的cookie中拥有了他的Github凭证,他只需点击我的登录按钮,他就在我的仪表板上。但是,如果他没有cookie,我的应用程序会暂时将他重定向到Github以输入他的凭据。
我想添加如果应用必须将用户重定向到Github的功能,请在新窗口中执行此操作。这可能吗?
在passport-github示例中调用了此函数,但显然在发生这种情况时我无法运行任何代码?
// GET /auth/github
// Use passport.authenticate() as route m function(req,res)iddleware to authenticate the
// request. The first step in GitHub authentication will involve redirecting
// the user to github.com. After authorization, GitHubwill redirect the user
// back to this application at /auth/github/callback
app.get('/auth/github',
passport.authenticate('github'),
function(req, res){
// The request will be redirected to GitHub for authentication, so this
// function will not be called.
});
答案 0 :(得分:0)
不幸的是,我没有足够的声誉来发表评论,但为什么你想让用户在另一个窗口重定向? github auth是否通过重定向将用户发送回您的应用程序?
也许试试:
window.open('/auth/github')