我的应用程序在本地运行,当我将其部署到Cloud Foundry时,身份验证失败(数据库相同)。代码:
exports.ssoCallback = function(req, res, next) {
passport.authenticate('sso-login', function(err, user, info) {
console.log(info);
if (err || !user) {
if (err) {
console.log(err);
}
if (!user) {
console.log("there was no user found when passport.authenticate");
}
var loginErrorParameters = '?success=false';
if (info.internalServerError) {
loginErrorParameters += '&error=internal';
} else if (info && info.code) {
loginErrorParameters += '&error=' + info.code;
}
return res.redirect('/#!/login' + loginErrorParameters);
}
req.logIn(user, function(error) {
if (error) {
return res.redirect('/#!/login?success=false')
};
res.redirect('/#!/login?success=true&client=' + req.session.auth.requestedClient);
});
})(req, res, next);
};
没有记录错误,用户设置为false。信息对象给我以下错误和堆栈跟踪:
Error: Invalid session state at handleCallback (/home/vcap/app/node_modules/ibmcloud-appid/lib/strategies/webapp-strategy.js:309:17) at WebAppStrategy.authenticate (/home/vcap/app/node_modules/ibmcloud-appid/lib/strategies/webapp-strategy.js:129:10) at attempt (/home/vcap/app/node_modules/passport/lib/middleware/authenticate.js:361:16) at authenticate (/home/vcap/app/node_modules/passport/lib/middleware/authenticate.js:362:7) at exports.ssoCallback (/home/vcap/app/api/user/api_user.js:153:7) Layer.handle [as handle_request] (/home/vcap/app/node_modules/express/lib/router/layer.js:95:5) at next (/home/vcap/app/node_modules/express/lib/router/route.js:137:13) Route.dispatch (/home/vcap/app/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/home/vcap/app/node_modules/express/lib/router/layer.js:95:5) at /home/vcap/app/node_modules/express/lib/router/index.js:281:22
(第153行是所提供代码中的倒数第二行)