我一直在尝试session.currentUser
使用id
、email
和属性创建一个points
属性。
我使用 Ember simple auth + Ember CLI和How to store the user in a session引用自定义身份验证器,但我无法弄清楚这些部分是如何组合在一起的。
我正在使用 Ember CLI。在我的index.html
,我有:
window.ENV['simple-auth'] = {
authorizer: 'simple-auth-authorizer:devise',
session: 'session:custom'
};
在initializers/custom-session.js
中,我有:
import Session from 'simple-auth/session';
import Devise from 'simple-auth-devise/authenticators/devise';
export default {
name: 'session:custom',
before: 'simple-auth',
initialize: function(container) {
container.register('session:custom', Devise);
Session.extend({
currentUser: function() {
var id = this.get('id');
var email: this.get('user_email');
var points: this.get('points');
if (!Ember.isEmpty(id)) {
return this.store.createRecord('user', {
id: id,
email: email,
points: points
});
}
}.property('id')
});
}
};
这在很多方面对我来说都是错误的,但经过几个小时的努力,这至少表明我正在努力完成什么。
我会非常感谢任何帮助。先感谢您!