javascript - How do I access session properties in ember-simple-auth? - Stack Overflow

I'm using a custom Facebook authenticator, very similar to the one given in the ember-simple-auth

I'm using a custom Facebook authenticator, very similar to the one given in the ember-simple-auth example. I inject the properties accountID and accessToken into the session here:

if (fbResponse.status === 'connected') {
  console.log("AccountID: " + fbResponse.authResponse.userID);
  Ember.run(function() {
  resolve({
     accessToken: fbResponse.authResponse.accessToken,
     accountID: fbResponse.authResponse.userID
  });
});

If I read the docs correctly, I should be able to access accountID using session.accountID in any controller. But, the only way I can find this is via session.store._lastData.accountID, which is probably not the right way to do it.

More specifically, in a controller, I have an action:

createRental: function() {
      var session = this.get('session');
      console.log(session.accountID); // undefined
      console.log(session.store._lastData.accountID); // '123456'

Does anyone with experience using ember-simple-auth know what the issue is? Thanks!

I'm using a custom Facebook authenticator, very similar to the one given in the ember-simple-auth example. I inject the properties accountID and accessToken into the session here:

if (fbResponse.status === 'connected') {
  console.log("AccountID: " + fbResponse.authResponse.userID);
  Ember.run(function() {
  resolve({
     accessToken: fbResponse.authResponse.accessToken,
     accountID: fbResponse.authResponse.userID
  });
});

If I read the docs correctly, I should be able to access accountID using session.accountID in any controller. But, the only way I can find this is via session.store._lastData.accountID, which is probably not the right way to do it.

More specifically, in a controller, I have an action:

createRental: function() {
      var session = this.get('session');
      console.log(session.accountID); // undefined
      console.log(session.store._lastData.accountID); // '123456'

Does anyone with experience using ember-simple-auth know what the issue is? Thanks!

Share Improve this question asked Mar 25, 2014 at 13:37 abeinsteinabeinstein 5524 silver badges11 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

You need to use get:

this.get('session.accountID')

or

var session = this.get('session');
session.get('accountID')

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745250046a4618623.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信