Ember ember-simple-auth覆盖routeIfAlreadyAuthenticated在应用程序路由中

时间:2016-08-26 01:24:02

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

如何覆盖if (navigator.userAgent.toLowerCase().indexOf("iphone") ==-1) { }else{ $(document).on('touchstart', 'input, select', function() { $('select, input').not(this).attr('disabled', 'disabled'); }).on('blur', 'input, select', function() { $('input, select').removeAttr('disabled'); }); }

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

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

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:2)

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'
};