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: Overzealous redirects prevent navigating to previous history items #2804

Closed
thomasheartman opened this issue Jan 3, 2023 · 2 comments
Closed

Comments

@thomasheartman
Copy link
Contributor

Describe the bug

There's a few places in the admin UI where you might get caught by overzealous redirects. When this happens, it becomes impossible to go back to the previous page.

I have identified the folllowing two places where it can happen:

  1. The login screen, especially when you get redirected.
  2. The projects screen if you get redirected there from the root (pro, enterprise) or the default project when you are redirected from the root (open source)

Steps to reproduce the bug

For the login screen, the easiest I've found to replicate this reliably is to

  1. log into Unleash
  2. Navigate to a project's page.
  3. Log out
  4. Now try the navigating to the previous history item and notice that you get redirected to the login page.
  5. Bonus! In another tab, navigate to the unleash instance's root, e.g. https://sandbox.getunleash.io/demo2
  6. Notice that you get redirected to the login page and that you can't return to where you were previously

The projects screen is similar:

  1. Ensure you're logged into the Unleash instance
  2. Navigate to the Unleash instance's root (e.g.https://sandbox.getunleash.io/demo2) from any web page.
  3. Notice you're redirected to /projects (pro, enterprise) or to the default project (open source).
  4. Try to go back: notice you're stuck (I have actually managed to break out of the open source loop after enough tries, but I'm not sure why)

Expected behavior

I expect that the redirect is "invisible" and not added to the history.

When navigating from an unrelated page to Unleash (such as from github.com), I expect the back button to take me back the previous web page.

When navigating from inside Unleash to the root (when you get redirected to /projects or /projects/default), I expect to be taken to the previous page I was visiting.

When navigating back in history after logging out, I expect to be able to go one step at a time. So if I try to navigate back across 6 pages that require logging in to see, I should be able to press "back" 6 times, each time getting a different redirect URL for the login screen.

Logs, error output, etc.

No response

Screenshots

Loom video for the login screen: https://www.loom.com/share/1dd44c2866e349eb87010c5ddb00c432

Loom video for the projects screen: https://www.loom.com/share/110fe359692445bea9a509d327ab61c0

Additional context

It seems likely that this may be caused by a wrongful use of the history API and a call to pushState instead of replaceState.

We use React Router for navigation purposes, and it seems (from the React Router Navigate docs) that the replace property should take care of this for us.

I've done some preliminary work on this and it seems that the frontend/src/component/common/LoginRedirect/LoginRedirect.tsx component is triggered (at least for the login redirects). That component does use the replace property, so that doesn't seem to be the cause.

I suspect there may be some interplay between the login redirect and the projects redirect that causes this loop, but I can't be sure.

Unleash version

commit hash: 6b5e25b

Subscription type

None

Hosting type

None

SDK information (language and version)

No response

@ivarconr ivarconr changed the title Overzealous redirects prevent navigating to previous history items fix: Overzealous redirects prevent navigating to previous history items Jan 19, 2023
@stale
Copy link

stale bot commented Feb 18, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 18, 2023
@stale stale bot removed the stale label Feb 28, 2023
@thomasheartman
Copy link
Contributor Author

@FredrikOseberg Didn't we fix this?

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

No branches or pull requests

2 participants