【发布时间】:2016-04-18 22:28:19
【问题描述】:
我的应用访问令牌每 10 分钟过期一次。我使用 ember simple auth 进行身份验证,但它是一个自定义身份验证器,因为我拥有的不仅仅是用户名和密码字段。我想使用 ember-simple-auth-token,但是在我的适配器中调用授权:jwt,它不起作用,显然是因为我没有使用它的身份验证器。
所以,我正在考虑使用每十分钟更新一次令牌的服务,例如http://www.davekerr.co/programming/2015/05/17/add-a-polling-service-to-your-ember-app/,所以我的问题是如何覆盖 sessionData 令牌。
我的自定义授权文件代码如下所示:
import Ember from 'ember';
import Base from 'ember-simple-auth/authorizers/base';
export default Base.extend({
authorize(sessionData, block) {
if (!Ember.isEmpty(sessionData.token)) {
block('Authorization', 'Bearer '+sessionData.token);
block('Content-Type', 'application/json');
}
}
});
【问题讨论】:
标签: authentication ember.js ember-simple-auth