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(client): reload after login/logout when url contains hash #1298

Merged
merged 2 commits into from
Feb 11, 2021

Conversation

balazsorban44
Copy link
Member

@balazsorban44 balazsorban44 commented Feb 11, 2021

What:

Reload the page after signIn or signOut is called, even if the URL contains a hash.

Why:

A small experiment:

  1. go to https://google.com#top
  2. open the inspector
  3. write window.location = "https://google.com#top"

Observe that "nothing" happens.

We use window.location = to reload the page after a successful login/logout, but it does not work in the above mentioned case.

How:

After window.location is set, check if the url contains a #, if it does, reload the page with window.location.reload()

Checklist:

- [ ] Documentation

  • Tests
  • Ready to be merged

This has been discovered in #1107 by @ThewBear, so the credit goes to them!

I re-created the PR, because we did some changes in our release process and unfortunately all open PRs are getting massive merge conflicts now. Since it was a small update, I did not wish to ask the original creator to fix all those issues. (Very sorry for the inconvenience! 🙏)

Fixes #532

@vercel
Copy link

vercel bot commented Feb 11, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nextauthjs/next-auth/9h9hzoev1
✅ Preview: https://next-auth-git-fix-reload-with-hash.nextauthjs.vercel.app

@github-actions github-actions bot added core Refers to `@auth/core` client Client related code labels Feb 11, 2021
@balazsorban44 balazsorban44 changed the title fix(client): reload page even if url contains hash fix(client): reload after login/logout when url contains hash Feb 11, 2021
@balazsorban44 balazsorban44 merged commit 6e28a07 into main Feb 11, 2021
@balazsorban44 balazsorban44 deleted the fix/reload-with-hash branch February 11, 2021 11:18
@github-actions
Copy link

🎉 This PR is included in version 3.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Client related code core Refers to `@auth/core`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

signIn callbackUrl contains a # at the end?
1 participant