I think the Meteor.Accounts attempts to log in “optimistically” or causes some kind of “race condition” such that it is trying to fetch data before the data is completely available. This is most apparent when completely reloading the application, it appears the user is briefly logging in.
For example, on my user collection, I have a recent key. When I go to /products, it should use this recent tag on the route.
The problem you are seeing is due to the fact that the user isn’t published to the client until the DDP connection is successfully established. You have a couple ways that you can handle this… The first one is to guard against falsey values when you expect an object, which is good practice anytime you fetch reactive data from mini-mongo like you are doing.
The second option is to install meteorhacks:fast-render which will publish your user data with the html for the initial page. This is my preferred option because it also stops a login screen from flashing up if the user refreshes the page. As a side note, you shouldn’t need to handle publishing the data for the current logged in user. That is taken care of by the accounts-base package.
Unfortunately, it seems like the accounts-ui package doesn’t publish the information I want to publish. It immediately returns without a few fields I want. I couldn’t find the correct configuration options in the docs to change the fields.
But your solution of fast render worked wonders with only one line added; thank you so much!