简体   繁体   English

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

[英]Ember Simple Auth different redirects after authentication

I'm using Ember simple auth in my app and it's working great, but I've run into a scenario that I'm having trouble getting around. 我在我的应用程序中使用Ember简单身份验证并且它运行良好,但我遇到了一个我无法绕过的情况。

The library lets you specify the route to redirect to after a successful authentication by overriding routeAfterAuthentication: 'index' . 该库允许您通过覆盖routeAfterAuthentication: 'index'来指定成功验证后重定向到的路由。 This is working fine, however, I'm finding myself in a situation where I want to have two different types of redirects. 这工作正常,但是,我发现自己处于一种我希望有两种不同类型的重定向的情况。 When a user first logs in, I want them to go to /dashboard , but when they first sign up and authenticate, I want them to go /settings . 当用户首次登录时,我希望他们转到/dashboard ,但是当他们首次注册并进行身份验证时,我希望他们进行/settings

I was hoping to be able to do something like this after successfully creating an account, but it's still trying to use the routeAfterAuthentication option for the transition: 我希望在成功创建帐户后能够执行类似的操作,但它仍在尝试使用routeAfterAuthentication选项进行转换:

var _this = this;

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

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

Is there a way to specify which route to transition to after authenticating on one-off basis? 有没有办法在一次性验证后指定要转换到哪条路线? Maybe there's a better way to log someone after they create an account without needing to go through the authenticate() method? 也许有更好的方法来记录某人创建帐户后无需通过authenticate()方法?

You can simply override the sessionAuthenticated method in the application route and implement your own logic. 您可以简单地覆盖应用程序路径中sessionAuthenticated 方法并实现您自己的逻辑。 Beware though that the default implementation will not always transition to routeAfterAuthentication -- if there's a previously intercepted transition stored in the session, sessionAuthenticated will retry that instead. 请注意,默认实现并不总是转换为routeAfterAuthentication - 如果会话中存储了先前截获的转换,则sessionAuthenticated将重试该转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM