import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
AuthenticatedRoute = Ember.Route.extend(AuthenticatedRouteMixin, {
// route you would like to redirect to after logout
authenticationRoute: "routes.login",
// ... your stuff ...
})
在根应用程序路由中使用也相应的mixin:
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';
ApplicationRoute = Ember.Route.extend(ApplicationRouteMixin, {
// route you would like to redirect to after login
routeAfterAuthentication: "routes.authenticated-route",
// ... your stuff
})
2 回答
在路由中使用经过身份验证的路由mixin,在身份验证后应该可以访问:
在根应用程序路由中使用也相应的mixin:
这取决于您的需求,您将如何使用它 . 您可以将它放在每个经过身份验证的路由中,或者例如您可以将其放在一个路由中(例如,称为“/ auth”)并将另一个经过身份验证的路由放入此路由中 . 这些路由中的每一个都将进行身份验证,您的路由结构可能如下所示:
您可以将其用于读取会话
处理你想要的任何东西 .
应用程序/ router.js
});
应用程序/路由/ index.js
用这个