Node.js 使用OAuth2保护nodejs应用程序,不会自动重定向到允许/拒绝页面
我已经建立了一个项目,用OAuth2保护sails应用程序: 我有一个授权码授予的问题,我没有设法解决 基本上,我遵循以下步骤:Node.js 使用OAuth2保护nodejs应用程序,不会自动重定向到允许/拒绝页面,node.js,oauth-2.0,sails.js,passport.js,oauth2orize,Node.js,Oauth 2.0,Sails.js,Passport.js,Oauth2orize,我已经建立了一个项目,用OAuth2保护sails应用程序: 我有一个授权码授予的问题,我没有设法解决 基本上,我遵循以下步骤: -运行sails应用程序 -运行unTrustedClient(示例文件夹中的节点unTrustedClient.js) -然后,我在web浏览器中发布以下URL: http://localhost:1337/oauth/authorize?client_id=O3UTGRFNI1&response_type=code&redirect_uri=htt
-运行sails应用程序
-运行unTrustedClient(示例文件夹中的节点unTrustedClient.js)
-然后,我在web浏览器中发布以下URL:
http://localhost:1337/oauth/authorize?client_id=O3UTGRFNI1&response_type=code&redirect_uri=http://localhost:1339&scope=http://localhost:1337
注意:客户端id的值是应用程序启动时在sails终端中为untrustedTestClient显示的值
这会将我重定向到“登录”页面,这很好
但是当我提交凭证时(me@gmail.com/password默认情况下)我被重定向到/index,而不是原始URL(上面的那个)
我需要重新发布上面的URL以显示对话框页面(带有允许/拒绝选项的页面)
我正在使用“连接确保登录”中间件
app.get('/oauth/authorize',
login.ensureLoggedIn(),
server.authorize(function(clientId, redirectURI, done) {
Client.findOne({clientId: clientId}, function(err, client) {
if (err) { return done(err); }
if (!client) { return done(null, false); }
if (client.redirectURI != redirectURI) { return done(null, false); }
return done(null, client, client.redirectURI);
});
}),
server.errorHandler(),
function(req, res) {
res.render('dialog', { transactionID: req.oauth2.transactionID,
user: req.user,
client: req.oauth2.client
});
}
);
如何修复此问题,以便在输入凭据后自动完成重定向