Ember ember-simple-auth 在应用程序路由中覆盖 routeIfAlreadyAuthenticated
Ember ember-simple-auth override routeIfAlreadyAuthenticated in application route
如何覆盖 routeIfAlreadyAuthenticated
?
一旦发生这种情况,它如何过渡到具有动态路段的路线?
我意识到我可以覆盖 sessionAuthenticated
;并以这种方式覆盖 routeAfterAuthentication
的功能。但是,routeIfAlreadyAuthenticated
是计算的 属性,它在 unauthenticated-route-mixin.js
mixin 的 beforeModel
中执行。
如有任何帮助,我们将不胜感激。
在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'
});
有效,仅此而已:
Error while processing route: session.login Assertion Failed: The route index was not found Error
以下内容也适用,但已弃用
在config/environment.js
中:
var ENV = {
...
};
ENV['ember-simple-auth'] = {
// authenticationRoute: 'login',
// routeAfterAuthentication: 'dashboard',
routeIfAlreadyAuthenticated: 'dashboard'
};
如何覆盖 routeIfAlreadyAuthenticated
?
一旦发生这种情况,它如何过渡到具有动态路段的路线?
我意识到我可以覆盖 sessionAuthenticated
;并以这种方式覆盖 routeAfterAuthentication
的功能。但是,routeIfAlreadyAuthenticated
是计算的 属性,它在 unauthenticated-route-mixin.js
mixin 的 beforeModel
中执行。
如有任何帮助,我们将不胜感激。
在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'
});
有效,仅此而已:
Error while processing route: session.login Assertion Failed: The route index was not found Error
以下内容也适用,但已弃用
在config/environment.js
中:
var ENV = {
...
};
ENV['ember-simple-auth'] = {
// authenticationRoute: 'login',
// routeAfterAuthentication: 'dashboard',
routeIfAlreadyAuthenticated: 'dashboard'
};