Wrestling with Meteor.logoutOtherClients()

Hi Everybody,

I’m trying to implement Meteor.logoutOtherClients()

  1. I’m not sure where to put it… for the moment, I put it in an autorunblock in my Template.frontend.created:

    Accounts.onLogin ->

And it works - but not always… Sometimes it just seems to ignore the call?

  1. How to detect a user was logged out? I saw this thread, but I would assume there was some call for this, or a surefire way. Because if someone lost their internet connection, this would aslo fire?

Did anyone implement this in a 100% effective way?

many thanks,


Accounts.onLogin doesn’t need to be called in your Template; you can call it anywhere. Meteor.logoutOtheClients can only be called client side however. So instead of putting this within an autorun in your Template, you could just define a file like accounts.js and make it available client side. So something like:


Accounts.onLogin(() => {

Have you tried registering an Accounts.onLogout callback?

Hi hwilison,

thank you for your response! I moved the logoutOtherClietns to a separate file and that seems to work (better). But the onLogout callback seems to work only if somebody actually logs out “manually”. What logoutOtherClients seems to do is more cut a client off. I can see a loss in connection with Meteor.status().connected, but that is also true if someone’s internet connection drops for a few seconds, so that does not work as expected. I was hoping there would be some way o actively tell a client they are being disconnected because of the double login, but for the moment there does not seem to be a way… :frowning:

Thanks for the pointer on the first issue though; that allready helps :slight_smile:



Hmm - onLogout should work when calling logoutOtherClients. As a quick example - let’s say you have the following in your /client/main.js file:

Accounts.onLogout(() => {
  console.log('hasta la vista!');

Here’s a quick screenshot of 2 separate browsers, showing the onLogout callback being called:

Hi Hugh,

sorry for my late response :frowning:
No, the onLogout does not get called on my app. In the log I can see this:

But I put

Accounts.onLogout ->
    console.log "bye"

in there right along the logoutOtherClients, but it does not get called… strange…?



I’ve added logoutOtherClients() inside Accounts.onLogin() the problem is onLogin() gets called without end when multiple tabs are open. Is this the expected behaviour?