admin管理员组

文章数量:1416331

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')

本文标签: javascriptHow do I access session properties in embersimpleauthStack Overflow