Hot Code Reload triggers unwanted page redirect with Accounts.onLogin


When a user is logged in and browsing a page, a page refresh or hot code reload triggers the Account.onLogin again.
This changes the route to the ‘welcome userX’ page because I’m using this hook to direct users after first login.
But I don’t want this behaviour if the user didn’t actually login but instead it is just a HCR or page refresh.


I’m using a ‘require login’ pattern with IronRouter to block secured pages.

Router.onBeforeAction(function () {
// all properties available in the route function
// are also available here such as this.params

if (!Meteor.userId()) {
  // if the user is not logged in, render the Login template
} else {
  // otherwise don't hold up the rest of hooks or our route/action function
  // from running;

On a somewhat related note, the onBeforeAction triggers 3 times after logging in or HCR or page refresh with different Router.current().url values:


The second two times is what I think is redirecting the user to the index page, but I don’t know why this is occuring. How do I find out what is working within IronRouter causing the url to change?