【问题标题】:Ember Simple Auth different redirects after authenticationEmber Simple Auth 身份验证后的不同重定向
【发布时间】:2014-08-13 19:24:55
【问题描述】:

我在我的应用程序中使用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() 方法?

【问题讨论】:

    标签: ember.js ember-simple-auth


    【解决方案1】:

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

    【讨论】:

    • marcoow,会话恢复时不会触发这个事件吧?
    • @marcoow 这是否可能在 Simple Auth 1.0.1 中不再可能?
    • @Apex sessionAuthenticationSucceeded 不再正确。相反,请覆盖 sessionAuthenticated 方法——我已经更新了 marcoow 的答案以匹配这些名称。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多