From 63d780e3e3234df9e859fab8954c397c40a0380c Mon Sep 17 00:00:00 2001 From: Vlad Los Date: Wed, 21 Jul 2021 16:20:01 +0300 Subject: [PATCH] ui: fix redirect to requested page after login if not logged user try to open some specific page it will be redirected to it after login. eventually we had this in place before, but it become not working due to bracking changes in react router library. Resolves: #67329 Release note(ui): fix redirect to originaly requested page after user login --- pkg/ui/src/redux/login.ts | 8 +++----- pkg/ui/src/views/login/loginPage.tsx | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/ui/src/redux/login.ts b/pkg/ui/src/redux/login.ts index 80fe6306e1f7..c08d326e324e 100644 --- a/pkg/ui/src/redux/login.ts +++ b/pkg/ui/src/redux/login.ts @@ -130,15 +130,13 @@ function shouldRedirect(location: Location) { } export function getLoginPage(location: Location) { - const query = !shouldRedirect(location) ? undefined : { - redirectTo: createPath({ + const redirectTo = !shouldRedirect(location) ? undefined : createPath({ pathname: location.pathname, search: location.search, - }), - }; + }); return { pathname: LOGIN_PAGE, - query: query, + search: `?redirectTo=${encodeURIComponent(redirectTo)}`, }; } diff --git a/pkg/ui/src/views/login/loginPage.tsx b/pkg/ui/src/views/login/loginPage.tsx index a7edc97df57c..18793cb0d4d4 100644 --- a/pkg/ui/src/views/login/loginPage.tsx +++ b/pkg/ui/src/views/login/loginPage.tsx @@ -105,7 +105,7 @@ export class LoginPage extends React.Component { const { location, history } = this.props; const params = new URLSearchParams(location.search); if (params.has("redirectTo")) { - history.push(params.get("redirectTo")); + history.push(decodeURIComponent(params.get("redirectTo"))); } else { history.push("/"); }