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

Setting homeRoutePath has no effect? #14

Closed madhan5000 closed 8 years ago

madhan5000 commented 9 years ago

Hello authors, it looks like homeRoutePath has no effect? I want to redirect after sign-in. It gets redirected back to '/' route.

here is my config. I using Meteor 1.2

AccountsTemplates.configure({
defaultLayout: 'appLayout',
  defaultLayoutRegions: {
  header : "header",
  footer: "footer"
},
defaultContentRegion: 'area',

showForgotPasswordLink: true,
overrideLoginErrors: true,
enablePasswordChange: true,
sendVerificationEmail: false,

//enforceEmailVerification: true,
//confirmPassword: true,
//continuousValidation: false,
//displayFormLabels: true,
forbidClientAccountCreation: true,
//formValidationFeedback: true,
homeRoutePath: '/plans', //<-- has no effect
//showAddRemoveServices: false,
//showPlaceholders: true,

negativeValidation: true,
positiveValidation:true,
negativeFeedback: false,
positiveFeedback:false,

// Privacy Policy and Terms of Use
//privacyUrl: 'privacy',
//termsUrl: 'terms-of-use',

});

my route

 FlowRouter.route('/plans', {
 triggersEnter: [AccountsTemplates.ensureSignedIn],
 action: function(params) {
     BlazeLayout.render("appLayout", {area: "plans"});
 }    });

Thanks for your help!

Code in Question : https://github.com/meteor-useraccounts/flow-routing/blob/master/lib/client/client.js#L142

the line above fails with my configuration.

splendido commented 9 years ago

You're right! It seems that the previous path always take precedence and the execution passes through this line even when you configure homeRoutePath.

I'll have a better look at this asap.

splendido commented 8 years ago

@madhan5000 I've had a better look at this.

The only case where homeRoutePath gets used is when you directly head to, e.g. http://your.app/signIn and your old session is resumed (i.e. you're already logged in...). In this case there's no previousPath and the client is redirected to homeRoutePath.

In case you're trying to force a redirect after a regular sign in, you can set the redirect field while configuring the signIn route:

AccountsTemplates.configureRoute(`signIn`, {
  redirect: `routeName or route path of function`
});

In any case the documentation needs to be corrected. Also the redirect option for routes should be documented for AccountsTemplates.configureRoute in the flow-routing package which is currently missing. See here for the relevant code and here for the corresponding section for the iron-routing.

cc: @jshimko

splendido commented 8 years ago

@madhan5000 AccountsTemplates.ensureSignedIn in any case should redirect you back to your /plans route after a successful login...

madhan5000 commented 8 years ago

@splendido Thanks for getting back to me. Yes, I agree clear documentation would definitely help for those who don't have any iron-router experience. Thanks again.

ilan-schemoul commented 8 years ago

then maybe finally accept my PR ? Or tell me or to ameliorate it, because I would like my work to prevent new user to waste as many times as me :) EDIT : oh okay sorry madhan, I hope @splendido will take a look at my PR then

madhan5000 commented 8 years ago

@NitroBAY I am not the original author or a contributor. Please contact @splendido