【发布时间】:2014-06-23 18:50:26
【问题描述】:
我目前正在尝试覆盖 Ember.SimpleAuth.ApplicationRouteMixin 类中的 sessionAuthenticationSucceeded,以便我可以通过传入的模型转换到我的 routeAfterAuthentication。
基本上是this.transitionTo(Configuration.routeAfterAuthentication, model);,但即使在执行Ember.SimpleAuth.ApplicationRouteMixin.reopen() 之后,我对函数的覆盖也不会被调用。那么我对这一切都错了吗? Mixins不能以这种方式重新打开吗?或者我应该以不同的方式将模型传递给routeAfterAuthentication 转换。
编辑:愚蠢的声誉限制,我自己会回答这个问题,但显然要等 8 个小时,所以现在是这个答案:
好吧,不完全确定这是否是正确的方法,但它确实有效。我正在查看这个示例:custom-server,我最终这样做是为了完成我想要的。
var applicationRoute = container.lookup('route:application');
var session = container.lookup('ember-simple-auth-session:main');
var store = container.lookup('store:main');
session.on('sessionAuthenticationSucceeded', function() {
var user = store.find('user', session.get('user_id'));
container.lookup('controller:application').set('content', user)
applicationRoute.transitionTo('profile.resume', user);
});
【问题讨论】:
标签: ember.js ember-simple-auth