以下代码目前有效但 If I remove the line with _setup then the outgoing requests don't have the Authorization header.
我觉得我不应该使用_setup函数,因为它不在文档中 .
我究竟做错了什么?
我正在使用最新版本的Ember和Ember-Simple-Auth以及Oauth密码授予 .
Ember.getOwner(this).lookup('authenticator:custom').restore(token).then(() => {
Ember.getOwner(this).lookup('session:main')._setup('authenticator:custom', token, true);
});
2 回答
Restore是一个便利功能,可在app启动和存储更改时运行 . 据我所知,它不是手动调用,而是应该在应用程序启动时自动触发并从会话数据恢复 . 无论您是通过手动调用还是尝试做什么,您都可以在authenticate钩子内部处理,将令牌作为参数传递 .
对自定义身份验证器的规范调用应该类似于
万一它可以帮助任何人,这就是我最终做的事情 .
routes/application.js (代码段)
authenticators/application.js