Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't login after logout and redirect #27

Open
joarobles opened this issue Jan 14, 2016 · 6 comments
Open

Can't login after logout and redirect #27

joarobles opened this issue Jan 14, 2016 · 6 comments

Comments

@joarobles
Copy link

I have the following configuration for useraccounts:

AccountsTemplates.configure({
  defaultLayout: 'baseLayout',
  defaultLayoutRegions: {},
  defaultContentRegion: 'content',
  defaultState: 'signUp',
  confirmPassword: false,
  onLogoutHook: function () {
    FlowRouter.go('atSignIn');
  },
});

And this is my flow route for handling logout:

FlowRouter.route('/logout', {
  action: AccountsTemplates.logout
});

The problem is that, whenever I log out I get redirected to the sign in view (as expected) but I won't be able to login again: when I enter the right credentials no errors are shown but the form won't dissapear. Any idea?

@mbernath
Copy link

I can confirm this problem exists.

I added a triggers.enter logger and found, that after sign-in the user is randomly getting redirected to /logout again. If I try for 5-10 times, I am getting redirected to my homeRoutePath.

@mbernath
Copy link

mbernath commented Feb 1, 2016

I found the cause of the problem: The flow-routing always stores the previous Route so that when ensureSignedIn sends a user back to sign-in, he can then be redirected to the previous page. That totally makes sense.

This just doesn't work if there is a route, which causes the user to be logged out. Then the previous route is "logout".

But this can easily be fixed:

Just name your logout route "logout" and add it to the "knownRoutes" like this:

AccountsTemplates.knownRoutes.push('logout');

That causes flow-routing to not remember the previous route. Then everything works as expected.

@joarobles
Copy link
Author

Yeah, that will do the trick! Thanks Marc!

@DanielDornhardt
Copy link

Thanks @mbernath - life saver - should go to the docs!

@garyebersole
Copy link

@mbernath Thanks!! Chased this for hours while refactoring my app to replace my own accounts system with useraccounts. Your solution saved me from falling back to my own mediocre implementation for user account management.

@stinghz
Copy link

stinghz commented Aug 3, 2016

AccountsTemplates.knownRoutes.push('logout');
That causes flow-routing to not remember the previous route.

Thanks @mbernath

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants