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
}
}
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
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With