我有一个 Ember.StateManager 用于管理登录用户的会话。如何检测用户在访问页面时是否登录,以便设置 initialState 属性?(因为他们可能已经更早登录并且仍然有 cookie)
App.userSessionStateManager = Em.StateManager.create({
initialState: 'signedout', // this should be dynamic
signedin: Em.State.createWithMixins({
enter: function(sm) {
this._super(sm);
console.log('entered signedin state');
},
exit: function(sm) {
this._super(sm);
console.log('exited signedin state');
}
}),
signedout: Em.State.createWithMixins({
enter: function(sm) {
this._super(sm);
console.log('entered signedout state');
},
exit: function(sm) {
this._super(sm);
console.log('exited signedout state');
}
}),
});