Search code examples
javascriptmeteoriron-router

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?


Solution

  • Try this and let me know:

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