Skip to content

Instantly share code, notes, and snippets.

@hexsprite
Created May 22, 2020 18:29
Show Gist options
  • Save hexsprite/923465cbff898bd4a586fc4cc8c8048e to your computer and use it in GitHub Desktop.
Save hexsprite/923465cbff898bd4a586fc4cc8c8048e to your computer and use it in GitHub Desktop.
Meteor JS: client-side version of Accounts.onLogin
// client-side version of Accounts.onLogin
export function onLoginUser(hook) {
Meteor.subscribe('allUserData', () =>
Tracker.autorun(function (computation) {
// waiting for user subscription to load
if (!_.get(Meteor.user(), 'services.google')) {
return
}
// cancel autorun now that we've authenticated
computation.stop()
hook()
})
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment