Skip to content

Commit

Permalink
Merge #67857
Browse files Browse the repository at this point in the history
67857: ui: fix redirect to requested page after login r=elkmaster a=elkmaster

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

Co-authored-by: Vlad Los <[email protected]>
  • Loading branch information
craig[bot] and vladlos committed Jul 23, 2021
2 parents 0478064 + 3852a0d commit 42ce127
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions pkg/ui/src/redux/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,15 @@ function shouldRedirect(location: Location) {
}

export function getLoginPage(location: Location) {
const query = !shouldRedirect(location)
const redirectTo = !shouldRedirect(location)
? undefined
: {
redirectTo: createPath({
pathname: location.pathname,
search: location.search,
}),
};
: createPath({
pathname: location.pathname,
search: location.search,
});
return {
pathname: LOGIN_PAGE,
query: query,
search: `?redirectTo=${encodeURIComponent(redirectTo)}`,
};
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/ui/src/views/login/loginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class LoginPage extends React.Component<Props> {
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("/");
}
Expand Down

0 comments on commit 42ce127

Please sign in to comment.