【问题标题】:Ember ember-simple-auth override routeIfAlreadyAuthenticated in application routeEmber ember-simple-auth 覆盖应用程序路由中的 routeIfAlreadyAuthenticated
【发布时间】:2016-08-26 01:24:01
【问题描述】:

你如何覆盖routeIfAlreadyAuthenticated

一旦发生这种情况,它如何过渡到具有动态路段的路线?

我意识到我可以覆盖sessionAuthenticated;并以这种方式覆盖routeAfterAuthentication 的功能。但是,routeIfAlreadyAuthenticated 是一个计算属性,在 unauthenticated-route-mixin.js mixin 中的 beforeModel 中执行。

任何帮助将不胜感激。

【问题讨论】:

    标签: javascript ember.js overriding ember-simple-auth


    【解决方案1】:

    app/session/route.js 中,执行以下操作:

    import Ember from 'ember';
    import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-route-mixin';
    
    export default Ember.Route.extend(UnauthenticatedRouteMixin, {
      routeIfAlreadyAuthenticated: 'dashboard'
    });
    

    它起作用了,不再是:

    处理路由时出错:session.login 断言失败:找不到路由索引错误


    以下内容也可以,但已弃用

    config/environment.js:

    var ENV = {
       ...
    };
    
    ENV['ember-simple-auth'] = {
       // authenticationRoute:          'login',
       // routeAfterAuthentication:     'dashboard',
       routeIfAlreadyAuthenticated:  'dashboard'
    };
    

    【讨论】:

    • 有关可用选项的详细信息,请参阅 API 文档:ember-simple-auth.com/api/classes/Configuration.html
    • 我什至不记得我为什么写这个问题。哈哈。但是,如果您提到没有某个错误不再出现,我假设有一个更新解决了我担心的任何问题。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-01
    • 1970-01-01
    相关资源
    最近更新 更多