iron-meteor / iron-router

A client and server side router designed specifically for Meteor.
MIT License
1.98k stars 413 forks source link

this.params.name not defined inside onBeforeAction #1474

Closed PolGuixe closed 8 years ago

PolGuixe commented 8 years ago

this.params.name used to return the template name in:

Router.onBeforeAction(function () {
  if (Meteor.userId()) {
    if (this.params.name == 'landingPage') {
      Router.go('/map');
      this.next();
    } else {
      this.next();
    }
  } else {
    Router.go('/');
    this.next();
  }
}, {
  except: ['signin']
});

However now is undefined

PolGuixe commented 8 years ago

Work around using Router.current().route.getName()altough I don't know if it's the best way.

chrisbutler commented 8 years ago

@PolGuixe when you say used to, do you mean with an older version of IR? getName() is actually the correct way to do it

PolGuixe commented 8 years ago

But should this.params.getName() work?

chrisbutler commented 8 years ago

per the guide (http://iron-meteor.github.io/iron-router/#getting-the-current-route) it should not

this.params is for accessing parts of the url. the name of the route doesn't fall into that category, hence the change in functionality

PolGuixe commented 8 years ago

Understood.

Many thanks,