我在我的应用程序中使用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 回答
您可以简单地覆盖
sessionAuthenticated
method in the application route并实现您自己的逻辑 . 请注意,默认实现并不总是转换为routeAfterAuthentication
- 如果会话中存储了先前截获的转换,sessionAuthenticated
将重试该转换 .