I want to set permission for one user can be login only one at the same time (from many browsers).
So I should use this method, or have any solution?
Now I use iron-router
, and use Router.onBeforeAction()
to check.
How to use Meteor.logoutOtherClients()?
I think what you want is to run Meteor.logoutOtherClients() when the user logs in, like this:
Accounts.onLogin(function () {
Meteor.logoutOtherClients();
});
I tried, but don’t work.
Accounts.onLogin(function () {
Meteor.logoutOtherClients(function(){
Router.go('/');
});
});
What does not work? Is the problem consisting of other clients not being logged out or the router not going to the correct URL?
If you do:
Accounts.onLogin(function () {
Meteor.logoutOtherClients(function(error){
console.log(error);
Router.go('/');
});
});
do you get any error logged?
I get error undefined
, when I login the first time with Chrome. after that I login with the same user on Firefox, I still get error undefined
, but the first on Chrome don’t work. It can’t logout, can’t get or insert data … and Router.go('/')
don’t work. On the other hand the second on Firfox is work fine.
Now I understand about this, but why it run on the first time for login.
I thinks that it should be run when the second of user login (have one online).
It has to always run to find out if there are any other clients logged in anyway.