Skip to content

Commit

Permalink
Fix login redirect for expired sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
jportner committed Feb 7, 2020
1 parent e6be475 commit 48aced7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import chrome from 'ui/chrome';
const module = uiModules.get('security');
module.service('autoLogout', ($window, Promise) => {
return () => {
const next = chrome.removeBasePath(`${window.location.pathname}${window.location.hash}`);
const next = `${window.location.pathname}${window.location.search}${window.location.hash}`;
$window.location.href = chrome.addBasePath(
`/logout?next=${encodeURIComponent(next)}&msg=SESSION_EXPIRED`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('Session Expiration', () => {

const url = await newUrlPromise;
expect(url).toBe(
`/foo/logout?next=${encodeURIComponent('/bar?baz=quz#quuz')}&msg=SESSION_EXPIRED`
`/foo/logout?next=${encodeURIComponent('/foo/bar?baz=quz#quuz')}&msg=SESSION_EXPIRED`
);
});
});
Expand Down
4 changes: 1 addition & 3 deletions x-pack/plugins/security/public/session/session_expired.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ export class SessionExpired {
constructor(private basePath: HttpSetup['basePath'], private tenant: string) {}

logout() {
const next = this.basePath.remove(
`${window.location.pathname}${window.location.search}${window.location.hash}`
);
const next = `${window.location.pathname}${window.location.search}${window.location.hash}`;
const key = `${this.tenant}/session_provider`;
const providerName = sessionStorage.getItem(key);
const provider = providerName ? `&provider=${encodeURIComponent(providerName)}` : '';
Expand Down

0 comments on commit 48aced7

Please sign in to comment.