I want restrict non logged in users from viewing some pages in my app by redirecting them to the login page. I use react, flow router and the react komposer. The problem is, Meteor.user()
first gives undefined and even-though the user is logged in, he gets re-directed into the login page. How can I fix this?
答案 0 :(得分:2)
您需要的方法是Meteor.loggingIn()
在重定向用户之前,您需要检查用户是否正在登录:
if(!Meteor.loggingIn() && !Meteor.userId()){
//do redirect to login page
}