meteor-event-horizon icon indicating copy to clipboard operation
meteor-event-horizon copied to clipboard

Compatiblity

Open Tarang opened this issue 11 years ago • 5 comments

Wonderful package @belisarius222!! I particularly find good use with the loggedIn event. I had to previously write an adequately long check.

Is it possible to have this loggedIn/loggedOut event on the server?

Tarang avatar Mar 21 '13 07:03 Tarang

Thanks, glad to hear it's useful!

I don't think this package will work on the server, since Deps is only defined client-side.

What I'd recommend to get the server to do something when a user logs in would be to have the client call a server-side method like so:

// client
EventHorizon.on('loggedIn',function(){ Meteor.call('onLogin'); });

// server
Meteor.methods({
  onLogin: function() {
    console.log('user logged in: '+this.userId);
  }
});

Would that work?

On Thu, Mar 21, 2013 at 12:46 AM, Tarangp [email protected] wrote:

Wonderful package @belisarius222 https://github.com/belisarius222!! I particularly find good use with the loggedIn event. I had to previously write an adequately long check.

Is it possible to have this loggedIn/loggedOut event on the server?

— Reply to this email directly or view it on GitHubhttps://github.com/belisarius222/meteor-event-horizon/issues/1 .

belisarius222 avatar Mar 22 '13 00:03 belisarius222

I'm using that at the moment, the trouble is the logout method. I can't use accounts-ui without modifying it because I have to employ a callback from Meteor.call to logout on the client. If I Meteor.call after logging out meteor won't be able to tell which user it was

Tarang avatar Mar 22 '13 04:03 Tarang

Hmm, you could maybe store the userId in a variable while logged in, like Meteor.previousUserId or something, and then when you get a loggedOut event on the client, run Meteor.call('onLogout',Meteor.previousUserId);

Not sure about the security implications of that approach.

On Thu, Mar 21, 2013 at 9:52 PM, Tarangp [email protected] wrote:

I'm using that at the moment, the trouble is the logout method. I can't use accounts-ui without modifying it because I have to employ a callback from Meteor.call to logout on the client. If I Meteor.call after logging out meteor won't be able to tell which user it was

— Reply to this email directly or view it on GitHubhttps://github.com/belisarius222/meteor-event-horizon/issues/1#issuecomment-15281198 .

belisarius222 avatar Mar 22 '13 19:03 belisarius222

Ah I see now. That is how I am making the call to the server. I wonder if it's possible to make EventHorizon work on server side as well?

It would be nice to have some sort of interface between the two that is hidden to the developer's eyes. But I guess this is not necessary as Meteor.call() is essentially same. The beauty of this would be you wouldn't have to have to expose all the Meteor.methods.

client.js EventHorizon.fire{'loggedin'}

server/events.js EventHorizon.on{'loggedIn', handleUser};

ghost avatar Mar 26 '13 05:03 ghost

@belisarius222 this is tricky because I would be able to trick the onLogOut method on the server with a random userId & not be able to verify its legitimate so it poses a bit of a security risk. I have meteor connecting to facebook's xmpp servers & I want to be able to tell them to log out, for now I'm using a callback & waiting to disconnect first.

Tarang avatar Mar 26 '13 07:03 Tarang