Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Meteor, how do you detect when a new user has logged in?

Tags:

meteor

The documentation:

http://docs.meteor.com/#publish_userId

says

This is constant. However, if the logged-in user changes, the publish function is rerun with the new value.

Is there some way of running some event driven code which fires only on the event that the logged in user changes?

like image 649
deltanovember Avatar asked Oct 29 '12 00:10

deltanovember


2 Answers

Meteor.user(), Meteor.userId() and Meteor.userLoaded() are all reactive datasources (documentation).

If you place them inside a template helper or build your own context around them, you'll notice when the current user changes.

like image 110
Andreas Avatar answered Nov 08 '22 20:11

Andreas


You can also do it via Subscription and you can track the user and log inside the server. See my blog

Navigate to the code section in the blog post.

like image 32
Arunoda Susiripala Avatar answered Nov 08 '22 18:11

Arunoda Susiripala