简体   繁体   中英

Meteor.user() is null when trying to check user login status

I am trying to show other some user's profile page to non-logged in and logged-in users. The problem is that whenever I check

if(Meteor.user() === me)

Meteor.user() returns null and code crashes since no one is logged in. How can I check whether there are logged in users?

Try this and let me know:

if (Meteor.user()) {
    // code for login user
} else {
    // code for non-login user
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM