最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Meteor login - logout ~ hookcallback - Stack Overflow

programmeradmin1浏览0评论

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 } }

Share Improve this question asked Apr 29, 2014 at 0:05 iwaniwan 7,56918 gold badges50 silver badges67 bronze badges 1
  • one solution here using iron-router and Meteor.user()/Meteor.loggingIn(): stackoverflow./questions/22900405/… – dm76 Commented Sep 22, 2014 at 9:42
Add a ment  | 

1 Answer 1

Reset to default 9

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
  }
});
发布评论

评论列表(0)

  1. 暂无评论