【问题标题】:How to wait for Meteor.user() and redirect if undefined from within the container?如果容器内未定义,如何等待 Meteor.user() 并重定向?
【发布时间】:2016-06-11 02:30:55
【问题描述】:

我想通过将未登录用户重定向到登录页面来限制未登录用户查看我应用中的某些页面。我使用 react、flow router 和 react komposer。问题是,Meteor.user() 首先给出 undefined 并且即使用户已登录,他也会被重定向到登录页面。我该如何解决这个问题?

【问题讨论】:

    标签: meteor flow-router


    【解决方案1】:

    你需要的方法是Meteor.loggingIn()

    在重定向用户之前,您需要检查用户是否正在登录:

    if(!Meteor.loggingIn() && !Meteor.userId()){
       //do redirect to login page
    }
    

    【讨论】:

      猜你喜欢
      • 2016-05-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-19
      • 1970-01-01
      相关资源
      最近更新 更多