Skip to content

Commit

Permalink
Merge pull request #67858 from elkmaster/bp-21.1-login-redirect
Browse files Browse the repository at this point in the history
ui: fix redirect to requested page after login [backport 21.1]
  • Loading branch information
vladlos authored Jul 23, 2021
2 parents 6157193 + 5d82333 commit cd004bd
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 cd004bd

Please sign in to comment.