[英]How do I access session properties in ember-simple-auth?
I'm using a custom Facebook authenticator, very similar to the one given in the ember-simple-auth example . 我使用的是自定义Facebook身份验证器,非常类似于ember-simple-auth 示例中给出的身份验证器。 I inject the properties accountID
and accessToken
into the session here: 我将属性accountID
和accessToken
注入到会话中:
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. 如果我正确阅读了文档 ,我应该能够在任何控制器中使用session.accountID
访问accountID
。 But, the only way I can find this is via session.store._lastData.accountID
, which is probably not the right way to do it. 但是,我能找到这个的唯一方法是通过session.store._lastData.accountID
,这可能不是正确的方法。
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? 有经验使用ember-simple-auth的人是否知道问题是什么? Thanks! 谢谢!
You need to use get
: 你需要使用get
:
this.get('session.accountID')
or 要么
var session = this.get('session');
session.get('accountID')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.