Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor login - logout ~ hook / callback

Using this package in MeteorJS accounts-google, I was trying to find the right approach to have a callback after user login & logout. Currently I am using below hook for login (which seems to me too simplistic -- i want to find a hook that triggered by callback after successful authentication) ~ and still not sure how to do for logout.

Meteor.autorun(function() { if (Meteor.user()) { //code for login } }

like image 353
iwan Avatar asked Apr 29 '14 00:04

iwan


1 Answers

UPDATE: There is now an onLogout hook


From what I have seen, there are no hooks for the logged out event, but there is one for logged in event:

Accounts.onLogin(func)

The event-hooks package adds an onLoggedOut hook.

You could also do something like this:

Meteor.autorun(function () {
  if (Meteor.userId()) {
    do something when logged in
  } else {
    do something when logged out
  }
});
like image 80
flynfish Avatar answered Sep 21 '22 06:09

flynfish