【发布时间】:2018-08-01 17:40:08
【问题描述】:
我正在使用 passport.js 和 auth0 策略来验证用户
我也在使用auth0的托管登录页面,这里支持customQueryParam等查询参数
例如:https://cool-startup.auth0.com/login?client=some_client_ID&...bunch of params...&customQueryParam=true
您可以使用customQueryParam 来控制auth0 托管的登录页面并显示flash 消息和东西,很方便
这是我的问题
在我的 auth0 中间件运行并且我确定我需要使用自定义参数将用户重定向回我的 auth0 登录页面之后,我应该如何在使用 passport.js 的上下文中实现这一点/这可能吗?
我在这里查看源代码 https://github.com/auth0/passport-auth0/blob/master/lib/index.js 继承自https://github.com/jaredhanson/passport-oauth2/blob/9ddff909a992c3428781b7b2957ce1a97a924367/lib/strategy.js
我有点难过
在这里我发现我有一个错误,我需要使用 url 中的自定义参数将用户重定向回 auth0
app.get('/auth/callback', (req, res, next) => {
passport.authenticate('auth0',
{},
(err, user) => {
if (err) {
// run passport.authenticate('auth0',
// again, but add custom query param
}
return res.redirect('/');
})(req, res, next);
});
任何帮助都非常感谢/感谢阅读
【问题讨论】:
标签: node.js passport.js auth0