Meteor only publishing 'email' from 'services.facebook' object for current user

Hey guys, this is a weird problem I am having. The logged in user is unable to access anything inside the services.facebook object other than email. The currentUser is published as

Meteor.publish(null, function() {
    if (this.userId) {
        return Meteor.users.find({_id: this.userId});
    } else {
        return null;
    }
}, {is_auto: true});

If I log in as another user and do Metero.users.find().fetch() and look into the user with my Facebook ID then I can see the the 4 fields that I publish for that user.

I hope Iā€™ve been clear enough. Any ideas what could be causing this?

Thanks

1 Like

Are you sure you wait for the publication to be ready before looking inside the user document?

Its an auto publication so I cant exactly move the subscribe function for it to the router and wait on it. And it doesnt matter at what stage I look into it, the only thing I see is the email. Iā€™ve tried accessing the information all possible ways and even the console doesnt show anything else but the email.

And two users using the app at the same time, currently on the same page ā€¦ user 2 can see user 1ā€™s Facebook data other than email but user 1 cannot see his own and vice versa.

Can you post the code you are using to publish the ā€œotherā€ usersā€™ data? Also, does doing meteor remove autopublish solve the problem?

I donā€™t have auto publish. I just tried autobpublish to see if that lets me see rest of my data but oddly even with auto publish on, I see only the email address inside the Facebook object. This is the code for the rest of the users thats published accordion to what anyone can access.

Meteor.publish('users', function() {
    
    if(this.userId) {
        if(Admins.find({admin: this.userId}).fetch().length > 0) {
            return Meteor.users.find();
        } else {
            return Meteor.users.find({}, {
                fields: {
                    'aboutMe': 1,
                    'profile.firstName': 1,
                    'profile.name': 1,
                    'profile.currentLocation': 1,
                    'profile.peerId':1,
                    'profile.profileType': 1,
                    'skills': 1,
                    'role': 1,
                    'education': 1,
                    'location': 1,
                    'currentLocation': 1,
                    'priceTier': 1,
                    'services.facebook.id': 1,
                    'services.facebook.first_name': 1,
                    'services.facebook.last_name': 1,
                    'services.facebook.gender': 1,
                    'createdAt': 1,
                }
            });
        }
    } else {
        return Meteor.users.find({}, {
            fields: {
                'emails': 0,
                'email': 0,
                'admin': 0,
                'approved': 0,
                'firstLogin': 0,
                'services.password': 0,
                'services.facebook.accessToken': 0,
                'services.facebook.email': 0,
                'registered_emails': 0,
                'profile.phone': 0
            }
	   });
    }
});

I suspect you are getting bitten by issue #3764. Your app, or one of the packages it uses, probably has another publication that publishes ā€˜services.facebook.emailā€™ to the current logged in user (or perhaps all users). As a result, different publications are providing conflicting values for the ā€˜servicesā€™ field of the same document and Meteor is picking one arbitrarily.

Hi @ggndpsingh, I was having the same issue.

Do you have okgrow:analytics installed? The issue IS related to what @brettle mentions. In my case it was a publication conflict caused by this package.

Luckily it was fixed just few days ago (Github analytics issue#57). I updated to 1.0.1 and got it working fine again.

Hey @juliomac

Thanks for that. My laptop is in for repairs at the moment. I believe I do have that package installed. Iā€™ll take a look if the problem is solved as soon as I get the laptop back

Cheers