身份验证后,Ember Simple Auth会进行不同的重定向

时间:2014-08-13 19:24:56

标签: ember.js ember-simple-auth

我在我的应用中使用了Ember simple auth并且工作得很好,但是我遇到了一个我无法绕过的情况。

通过覆盖routeAfterAuthentication: 'index',您可以通过库指定成功进行身份验证后重定向到的路由。这很好,但是,我发现自己处于一种我希望有两种不同类型的重定向的情况。当用户首次登录时,我希望他们转到/dashboard,但是当他们首次注册并进行身份验证时,我希望他们转到/settings

我希望在成功创建帐户后能够执行此类操作,但它仍在尝试使用routeAfterAuthentication选项进行转换:

var _this = this;

this.set('identification', _this.get('email'));
this.set('password', password);

this.send('authenticate', function() {
  _this.transitionToRoute('settings');
}, function() {});

有没有办法在一次性验证后指定要转换到哪条路线?也许有更好的方法可以在创建帐户后记录某人而无需通过authenticate()方法?

1 个答案:

答案 0 :(得分:8)

您可以简单地覆盖sessionAuthenticated method in the application route并实现自己的逻辑。请注意,默认实现并不总是转换为routeAfterAuthentication - 如果会话中存储了先前截获的转换,sessionAuthenticated将重试该转换。

相关问题