Ember-未调用简单验证自定义授权方
Ember-simple-auth custom authorizer not called
我正在尝试使用 ember-simple-auth 实现自定义身份验证,但一开始就卡住了。我有 app/autheticators/digest.js
import Base from 'ember-simple-auth/authenticators/base';
import Ember from 'ember';
export default Base.extend({
restore(data) {
//
},
authenticate(email, password) {
console.log(email, password);
return new Ember.RSVP.Promise(function(resolve, reject) {
Ember.run(function() {
resolve({email: email, password: password});
});
});
},
invalidate(data) {
//
}
});
app/authorizers/digest.js
import Base from 'simple-auth/authorizers/base';
import Ember from 'ember';
export default Base.extend({
header: function() {
return "test-digest";
},
authorize: function(sessionData, block) {
console.log('authorize...');
block('Authorization', this.get('header'));
}
});
登录组件:
import Ember from 'ember';
import CryptoJS from 'npm:crypto-js';
export default Ember.Component.extend({
session: Ember.inject.service('session'),
actions: {
login() {
let { email, password } = this.getProperties('email', 'password');
this.get("session").authenticate('autheticator:digest',
email, CryptoJS.SHA256(password).toString()).catch((reason) => {
this.set('errorMessage', reason.error);
});
}
}
});
正确调用了身份验证(我希望如此),但 "authorize" 从未在授权方中调用过。我还尝试向 ENV 添加一些值:
ENV['simple-auth'] = {
authorizer: 'authorizer:digest',
crossOriginWhitelist: ['http://prod-drunkedguru.rhcloud.com:80/'] // ['*'] I also tried
};
但没有任何改变。我做错了什么?
P.S。我在 EAS 1.0 中使用 EmberJS 1.13.0。
我假设您使用的是 ESA 1.0。在该版本中,不再自动调用授权方,但您需要手动调用它。不过,您可以使用 DataAdapterMixin
来自动授权 Ember 数据请求。有关迁移到 1.0 的指南,请参阅此博客 post:http://log.simplabs.com/post/131698328145/updating-to-ember-simple-auth-10
我正在尝试使用 ember-simple-auth 实现自定义身份验证,但一开始就卡住了。我有 app/autheticators/digest.js
import Base from 'ember-simple-auth/authenticators/base';
import Ember from 'ember';
export default Base.extend({
restore(data) {
//
},
authenticate(email, password) {
console.log(email, password);
return new Ember.RSVP.Promise(function(resolve, reject) {
Ember.run(function() {
resolve({email: email, password: password});
});
});
},
invalidate(data) {
//
}
});
app/authorizers/digest.js
import Base from 'simple-auth/authorizers/base';
import Ember from 'ember';
export default Base.extend({
header: function() {
return "test-digest";
},
authorize: function(sessionData, block) {
console.log('authorize...');
block('Authorization', this.get('header'));
}
});
登录组件:
import Ember from 'ember';
import CryptoJS from 'npm:crypto-js';
export default Ember.Component.extend({
session: Ember.inject.service('session'),
actions: {
login() {
let { email, password } = this.getProperties('email', 'password');
this.get("session").authenticate('autheticator:digest',
email, CryptoJS.SHA256(password).toString()).catch((reason) => {
this.set('errorMessage', reason.error);
});
}
}
});
正确调用了身份验证(我希望如此),但 "authorize" 从未在授权方中调用过。我还尝试向 ENV 添加一些值:
ENV['simple-auth'] = {
authorizer: 'authorizer:digest',
crossOriginWhitelist: ['http://prod-drunkedguru.rhcloud.com:80/'] // ['*'] I also tried
};
但没有任何改变。我做错了什么?
P.S。我在 EAS 1.0 中使用 EmberJS 1.13.0。
我假设您使用的是 ESA 1.0。在该版本中,不再自动调用授权方,但您需要手动调用它。不过,您可以使用 DataAdapterMixin
来自动授权 Ember 数据请求。有关迁移到 1.0 的指南,请参阅此博客 post:http://log.simplabs.com/post/131698328145/updating-to-ember-simple-auth-10