Closed rclai closed 9 years ago
I think this use case is why I created https://github.com/mizzao/meteor-user-status.
Determining when a user has logged out is tricky, and I don't think it's the job of this package to do that.
Yes, but my use case is that of using an update hook on Meteor.users to do something when someone has updated their user profile.
What does that have to do with logging in/out?
When someone logs in or out, the same update hook gets triggered when I'm updating a user profile. Does that make sense?
There are all kinds of other existing user collection operations that would also trigger your hook aside from logging out, including changing passwords, pulling expired login tokens, etc.
Rather than trying to put some specific functionality in this package, it seems like your best bet is to check if a particular update is acting on the profile
field and to then take an appropriate action.
Better yet, you might want to use observeChanges
on a livedata query that includes profile
and use the callbacks provided. You don't even need hooks for that.
Okay, I'll manage. Thanks.
If I create an update hook on the Meteor.users collection, there doesn't seem to be a nice way to check whether the user is logging in or logging out, except that when logging in, userId is empty and when logging out, the userId is still there and all you have is a modifier that is pulling a loginToken out of the user document and that's it.
Is there a way to expose some kind of this.loggingIn/this.loggingOut flag inside the hook?