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

Fix: no more redirect on direct load / refresh of a page. #158

Merged
merged 1 commit into from
Apr 27, 2018

Conversation

SnooHD
Copy link
Contributor

@SnooHD SnooHD commented Apr 26, 2018

If you load a page with auth directly from the URL bar (or refresh the page) you will allways be redirected to home. This is simply because the user gets re-logged in, and the watcher will trigger the loggedIn redirect.

Now, as soon as we move to another page, this.ctx.from is being added so we know the previous page.
This means that on the initial load, ctx.from is not avaible.

Because of that, a check in the watchState to see if ctx.from excists should disable the redirect only on first direct load of a page.

@pi0 pi0 merged commit 0386eb9 into nuxt-community:dev Apr 27, 2018
@pi0
Copy link
Member

pi0 commented Apr 27, 2018

Thanks!

@SnooHD SnooHD deleted the auth-dev branch April 27, 2018 15:20
@ghost
Copy link

ghost commented May 15, 2018

But the refresh is still redirected
tim 20180515163032
tim 20180515163050

@SnooHD
Copy link
Contributor Author

SnooHD commented May 15, 2018

@BIGzs i am unable to reproduce this..
For me this.ctx.from is undefined on refresh.

@jon-mckinney
Copy link

I can confirm @BIGzs's behavior in Firefox. Direct page request or refresh after logging in, the this.ctx.from value is populated. Even when clicking a link within the site as an authenticated user is triggering a redirect. Perhaps I'm not following the intended behavior here?

In Chrome all works as expected.

@ghost
Copy link

ghost commented May 16, 2018

@SnooHD @subsociety @pi0
I use Chrome
3

@pi0
Copy link
Member

pi0 commented May 18, 2018

I've reverted this because not working and making unwanted behaviours. A reproduction repository would be much appreciated for a fix.

PS: I think this bug is probably because Cookies are not set and SSR side does not detect loggedIn status.

pi0 pushed a commit that referenced this pull request May 18, 2018
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

Successfully merging this pull request may close these issues.

3 participants