title: How to get logged-in user email in publish functions in meteor?
body: <p>I've created a meteor 0.5.4 app - added accounts-ui, accounts-password, and added {{loginButtons}} to the template name="hello" block hat comes stock with every meteor create. </p>
  
  <p>When I type this in a chrome browser console, Meteor.user().emails[0].address as per these SO sources - <a href="http://goo.gl/MTQWu" rel="nofollow">http://goo.gl/MTQWu</a>, <a href="http://goo.gl/Cnbn7" rel="nofollow">http://goo.gl/Cnbn7</a> - I get the currently logged in users email. </p>
  
  <p>When I attempt to put the same code within the if (Meteor.isClient) section : </p>
  
  <pre><code>Template.hello.greeting = function () {
     return Meteor.user().emails[0].address;
  };
  </code></pre>
  
  <p>I get : </p>
  
  <pre><code> Uncaught TypeError: Cannot read property '0' of undefined foo.js:3
   Exception from Meteor.flush: TypeError: Cannot call method 'firstNode' of undefined
  </code></pre>
  
  <p>If you can't place Meteor.user() within publish functions, how else can I get the email of the logged in user? I've tried making it a shared function, and calling it within the client side function with Meteor.call('getEmail', Meteor.userId()) with similar results.</p>