【发布时间】:2016-08-01 17:32:03
【问题描述】:
我成功地与这些人建立了堆栈。它是一种与 Oracle 数据库交互的表单。
现在我正在添加身份验证,要求使用 nodejs 的“client-oauth2”模块将其发送到 OAuth2 服务器。这是 Node.js 中的代码:
requireLogin = function (req, res, next) {
var uri=ServAuth.code.getUri();
res.redirect(uri);
};
app.get('/auth/callback', function (req, res) {
ServAuth.code.getToken(req.url)
.then(function (user) {
console.log(user); //=> { accessToken: '...', tokenType: 'bearer', ... }
user.request({
method: 'get',
url: 'https://aut.server.blabla.bla/api/Me'
}).then(function (res) {
res.body.forEach(function (item){
if (item.Type=="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name") {
logged_user=item.Value;
}
});
})
return res.sendFile(path.resolve(__dirname + '/../public/form.html')); // load the single view file (angular will handle the page changes on the front-end)
});
});
app.use('/form', requireLogin);
如果我调用“myserver.bla/form”,我会正确重定向到 OAuth2 服务器的登录页面;然后我登录并授予访问权限。 然后页面“form.html”被加载,但我在浏览器控制台中看到错误:
错误:[$injector:modulerr] 无法实例化模块 NSW_PCB_QC 由于: [$injector:nomod] 模块“NSW_PCB_QC”不可用!
请注意,NSW_PCB_QC 是 Angular 应用程序的名称 (ng-app="NSW_PCB_QC")。
但是如果我直接加载form.html,绕过身份验证,调用“myserver.bla/form.html”,那么所有的角度模块都被正确加载了。
问题出在哪里?
提前谢谢你
【问题讨论】:
-
可以显示form.html的内容吗?
-
嗨@ruedamanuel,感谢您的关注。 form.html 为 320 行。您认为哪一部分有帮助?
-
我想查看您正在加载的 js 脚本的路径,因为您的 html 中的相对路径似乎引用了 /form 路由场景中不存在的内容,因为可能缺少静态文件位置声明(只是一个理论)
-
好的,这些是声明:
-
尝试在每个路径前添加 /。我的猜测是,它们在您描述的两种情况下的根源并不相同。
标签: javascript angularjs node.js express oauth-2.0