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
}
}
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
}
}
- one solution here using iron-router and Meteor.user()/Meteor.loggingIn(): stackoverflow./questions/22900405/… – dm76 Commented Sep 22, 2014 at 9:42
1 Answer
Reset to default 9UPDATE: 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
}
});