【发布时间】:2014-08-14 00:48:51
【问题描述】:
我一直在尝试使用id、email 和points 属性创建session.currentUser 属性。
我引用了 Custom authenticator with 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')
});
}
};
这在很多方面对我来说都是错误的,但经过几个小时的努力,这至少表明我正在努力完成什么。
如果能提供任何帮助,我将不胜感激。提前谢谢!
【问题讨论】:
标签: ember.js ember-simple-auth