Is this a bug? Accessing services.facebook and services.twitter in rendered section via this.data

Hi,

So yeah, I’m trying to debug what happens after the social login thing in my app. So I’m using the FB and Twitter social logins. I’m trying to access user data from Meteor.users (because this is a profile page) right after the login and need to access the data in the rendered section of a template. So my code looks like this:

Template.profile.rendered = function() {
var self = this;
console.log(self.data);
// Do something with this.data.
}

I’m using Iron Router and I have it so that the subscription publishes all of the user’s properties for testing purposes. I noticed that:

  1. When I’m logged in for the first time as a facebook user, this.data.services and this.data.services.facebook exists.
    —However—
  2. When I’m logged in for the first time as a Twitter user, this.data.services is missing.

If I do a Meteor.user() in the console, I can see that in both cases, both are there, but why is it the above the case for this.data in the rendered() section?

Generally speaking, data is not always available to a template when it is first rendered.

Rendered means “hey I (the template) am here and I will now look for the data”

What you can do is wrap a Tracker around your console.log(self.data) to set up a reactive computation on your users client side collection and console.log(self.data) the changes as they come in.

Regarding the difference with Facebook and Twitter, well, it may be related to the difference in response times you get from their authentication services. Facebook’s might just be fast enough so you get that data as soon as the template renders while Twitter’s is lagging behind.

PS: I’m not exactly sure about that last paragraph, but my gut instinct says that should be crossed off the list first.

Ah, that must be it. But anyway, I just resorted to using template helpers and using Sessions to get and store the data from a reactive source and access it in the rendered block.

Not sure if you already noticed that meteor has updated tonight to release 1.0.5 and made some updates to facebook api https://github.com/meteor/meteor/blob/devel/History.md - Maybe you have a look on that either