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

Push State makes redirect reload complete app on login/logout #55

Closed
MarcScheib opened this issue Nov 21, 2015 · 4 comments
Closed

Push State makes redirect reload complete app on login/logout #55

MarcScheib opened this issue Nov 21, 2015 · 4 comments

Comments

@MarcScheib
Copy link

Hi Paul,

I have aurelias push state configured on my router config config.options.pushState = true;.

This causes the application to reload instead of simply navigating to the defined routes on login/logout.

Instead, when I use e.g. this.router.navigate('/contents');, the navigation is working without reloads.

In your code I can see you were testing the router navigate. Was it not working?

Another idea would be to decouple setToken() and logout() from redirecting so I can call them directly and do the routing on my own.

Right now, for the login I use the following solution:

  • explicitly set the loginRedirect config to '' so the complete if-else block will be skipped loginRedirect: ''
  • in my signin.js I inject the router and do:
    return this.auth.login(userInfo)
      .then(response => {
        console.log('You signed in successfully.');
        this.router.navigate('/contents');
      })

This fixes the reload of my page and still does a redirect.

However, for the logout, this is no completely working right now. I need to check this again, but when I set logoutRedirect to '' (logoutRedirect: '') it seems like the promise is not resloving. I will reply on this later.

Perhaps I am doing something wrong? Thank you for your reply.

@MarcScheib
Copy link
Author

The logout() in authService seems to miss a call on resolve(). As soon as I add this, my logout described in the first post works as well.

@RWOverdijk
Copy link
Contributor

@MarcScheib As far as I know, you might want the reload so the browser will ask you to save the password.

I do agree that some flexibility here might be nice. I'd propose allowing a false value, which will leave the redirecting to the user.

@MarcScheib
Copy link
Author

@RWOverdijk Good point. Strange thing is that with my approach I get asked by the browser to store the password. But the prompt appears after the next navigation, not on the one caused by the login navigation.

@RWOverdijk
Copy link
Contributor

Are you sure it's not doing a hard redirect? If not I'm curious how you nailed that :) Anyway, feel free to open up a PR! 🍻

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

2 participants