Weird behavior when accessing user object during the onLogin


#1

Hi all,

I put the onLogin code into lib/router.coffee like this

Accounts.onLogin(->
  console.log Meteor.user()
);

When starting the server, i got the error

Exception in onLogin callback: Error: Meteor.userId can only be invoked in method calls. Use this.userId in publish functions.

However, the log message is still displayed on the console log of Chrome. So, what is the correct way to access the user after logging into my app ?


#2

Please ignore the question. it should be either on the client side or the server side, not in the place that can access by both client and server.

Cheers, folks