Skip to content

Commit

Permalink
fix: Redirect to full url on 401 (apache#19357)
Browse files Browse the repository at this point in the history
* Redirect to full url

* Redirect to full url

* Update test
  • Loading branch information
geido authored and philipher29 committed Jun 9, 2022
1 parent 5a9dc5d commit 086fe52
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ import { DEFAULT_BASE_URL, DEFAULT_FETCH_RETRY_OPTIONS } from './constants';

const defaultUnauthorizedHandler = () => {
if (!window.location.pathname.startsWith('/login')) {
window.location.href = `/login?next=${
window.location.pathname + window.location.search
}`;
window.location.href = `/login?next=${window.location.href}`;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,7 @@ describe('SupersetClientClass', () => {
const mockRequestUrl = 'https://host/get/url';
const mockRequestPath = '/get/url';
const mockRequestSearch = '?param=1&param=2';
const mockRequestRelativeUrl = mockRequestPath + mockRequestSearch;
const mockHref = `http://localhost${mockRequestRelativeUrl}`;
const mockHref = mockRequestUrl + mockRequestSearch;

beforeEach(() => {
originalLocation = window.location;
Expand Down Expand Up @@ -542,7 +541,7 @@ describe('SupersetClientClass', () => {
error = err;
} finally {
const redirectURL = window.location.href;
expect(redirectURL).toBe(`/login?next=${mockRequestRelativeUrl}`);
expect(redirectURL).toBe(`/login?next=${mockHref}`);
expect(error.status).toBe(401);
}
});
Expand Down

0 comments on commit 086fe52

Please sign in to comment.