meteor-useraccounts / flow-routing

Useraccounts packages add-on for integration with Flow Router and Blaze Layout.
https://atmospherejs.com/useraccounts/flow-routing
MIT License
72 stars 50 forks source link

Override AccountsTemplates.configureRoute #19

Open raduchiriac opened 8 years ago

raduchiriac commented 8 years ago

I am using a TelescopeApp (v0.25.5) and I need to edit the route paths and templates for "sign-in" and "sign-up". These are already declared under /telescope-users/lib/config.js

When I do:

AccountsTemplates.configureRoute('signIn', {
    name: 'landing',
    path: '/landingPage',
    template: 'landingPage'
});

I get an error saying: Route already configured! Is there a way I can override a previously (from the packages) declared route?

raduchiriac commented 8 years ago

I've managed to do this little "cleanup" before configuring my own route. Quite ugly IMO delete AccountsTemplates.routes.signIn;

splendido commented 8 years ago

the thing is that the first call to configureRoute actually set the route using the router API... so, in principle, you should also cancel route configuration on the router: are you getting any problem with your current solution?

raduchiriac commented 8 years ago

Nope. Deleting the key on that object gives you the option to "overwrite" an already set route. I'm not sure if you can close this. Let's just say, I found a hack not a solution. Thanks for a great package anyway!

splendido commented 8 years ago

In case we're sure it's not a problem to configure the same route twice with flow-router, we can avoid checking whether the route is already set up (i.e. we could remove these lines).

@arunoda, do you think it would be a problem doing something like the following?

FlowRouter.route('/one/path', {
      name: 'myRoute',
      // Other options here...
});

FlowRouter.route('/another/path', {
      name: 'myRoute',  // same name as above!
      // Other different options here...
});

which is trying to change options (including path...) for a named route already defined.

arunoda commented 8 years ago

It won't be an issue for the route name. But configuring the same route definition twice will be problematic.

splendido commented 8 years ago

@arunoda is there any way to undo or cancel a route definition so that a new call to FlowRouter.route could then be safely performed?

Edit: alternatively, is there any way to change the options for an already defined route?

JulianKingman commented 8 years ago

Thanks for the hack @raduchiriac, I ran into the same thing with telescope. Im interested to know if theres a superior solution.

nicholasalanbrown commented 8 years ago

Any updates on this? @raduchiriac 's hack did not work for me when trying to set a different layout for the '/sign-in' route.

meshekhar commented 8 years ago

I have the same issue, can't set a different layout to the signIn route. Any updates please? @raduchiriac

Sureshkumar5694 commented 7 years ago

@raduchiriac have you found any solution for this issue? If you have found any , pls share with us. i also need to set different layout for signUp in the AccountTemplates.

raduchiriac commented 7 years ago

It's not a solution but a work-around. It's more than a year ago so I don't remember everything but checking my answer above, I think I was doing this:

delete AccountsTemplates.routes.signUp;
AccountsTemplates.configureRoute('signUp', {
  name: 'signUp',
  path: '/sign-up',
  template: 'register'
});