首页 文章

使用Ember Simple Auth,如果用户在页面上需要登录才能查看,如何重定向到登录页面?

提问于
浏览
0

使用Ember Simple Auth时,如果用户试图查看他们只能在登录时才能访问的页面,如何将用户重定向到登录页面?

1 回答

  • 2

    您只需在 Route 中导入 AuthenticatedRouteMixin

    import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
    

    并像这样使用它:

    export default Ember.Route.extend(AuthenticatedRouteMixin);
    

    这将使路由(及其所有子路由)在未对会话进行身份验证时转换为可配置的登录路由 .

    更多信息here .

相关问题