Session 如何使用Ember Simple Auth获取自定义会话的属性

Session 如何使用Ember Simple Auth获取自定义会话的属性,session,ember.js,ember-simple-auth,authenticator,Session,Ember.js,Ember Simple Auth,Authenticator,问题:我不知道如何在控制器中获取当前会话 我有一个自定义验证器、自定义会话和初始值设定项,定义如下: ../app/authenticators/CUSTOM.js中的自定义验证器 ../app/sessions/CUSTOM.js中的自定义会话 ../app/initializers/authentication.js中的初始值设定项 我试图通过使用此获取我的一个控制器中的令牌和用户数据。获取“会话”,但它提供了以下信息: Class {store: Class, __ember1420041

问题:我不知道如何在控制器中获取当前会话

我有一个自定义验证器、自定义会话和初始值设定项,定义如下:

../app/authenticators/CUSTOM.js中的自定义验证器

../app/sessions/CUSTOM.js中的自定义会话

../app/initializers/authentication.js中的初始值设定项

我试图通过使用此获取我的一个控制器中的令牌和用户数据。获取“会话”,但它提供了以下信息:

Class {store: Class, __ember1420041799205: "ember297", __nextSuper: undefined, __ember_meta__: Object, constructor: function…}
我在本地浏览器存储{authenticator:authenticator:custom,token:123456789,userData:{id:1,email:something@email.com,api_key:123456789,到期时间:2014-12-3114:02:56}


我基本上需要获取本地存储中的内容。我该怎么做?

啊,我解决了这个问题。第一次身份验证时,会话变量存在,但刷新页面会删除会话的内容,因为我的身份验证程序中没有还原功能

  restore: function(data) {
    return new Ember.RSVP.Promise(function (resolve, reject){
      console.log('RESTORE');
      if(!Ember.isEmpty(data.token)) {
        console.log('Found token: ' + data.token);
        resolve(data);
      } else {
        console.log('Token Not Found!');
        reject();
      }
    });
 }
import CustomAuthenticator from '../authenticators/custom';
import CustomSession from '../sessions/custom';

export default {
  name:       'authentication',
  before:     'simple-auth',
  initialize: function(container) {
    container.register('authenticator:custom', CustomAuthenticator);
    container.register('session:custom', CustomSession);
  }
};
Class {store: Class, __ember1420041799205: "ember297", __nextSuper: undefined, __ember_meta__: Object, constructor: function…}
  restore: function(data) {
    return new Ember.RSVP.Promise(function (resolve, reject){
      console.log('RESTORE');
      if(!Ember.isEmpty(data.token)) {
        console.log('Found token: ' + data.token);
        resolve(data);
      } else {
        console.log('Token Not Found!');
        reject();
      }
    });
 }