我正在使用passport.js和auth0策略
我还使用Auth0的托管登录页面,该页面支持查询参数,例如customQueryParam
此处
ex: https://cool-startup.auth0.com/login?client=some_client_ID&...bunch of params...&customQueryParam=true
您可以使用customQueryParam
来控制Auth0托管的登录页面并显示Flash Messages and stuct,它的方便
这是我的问题
我的auth0中间件运行并确定我需要使用自定义参数将用户重定向到我的auth0登录页面,我应该如何在使用Passport.js/的上下文中完成此操作?
我在这里查看源代码https://github.com/auth0/passport-auth0/blob/master/lib/index.js从https://github.com/jaredhanson/passport-oauth2/blob/9ddff9092c3428781b7b2957ce1a97a924367/
我有点困难
这是我发现我有错误的地方,我需要在url
中使用自定义参数将用户重定向到auth0app.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);
});
任何帮助都非常感谢/感谢您阅读
您可以自己构建/authorize
URL,并手动重定向:https://github.com/auth0-samples/auth0-reth0-regular-regular-webapp-login-with-sso-sso-sso-and-and-and-and-and-and-and-and-sso-and-and-and-and-sso-and-and-and-sso-and-and-and-sso-and-and-and-sso-and-and-sso-and-and-sso-and-an--api/blob/master/utils/授权.js
由于URL在您的控件中在此处,因此您可以按照您的需求添加任何查询参数(尽管将非标准查询参数发送到登录页面是通常灰心的(。