Skip to content

Commit 1e645cd

Browse files
committed
fix: logging-in should not navigate to auth/logout (#407)
* When the logout button is clicked in development mode, the app navigates to /auth/logout, which in turn sets up a redirect_uri to the root uri. However, redirecting preserves the logout uri as the final target uri and ends up displaying a blank page. * If the current uri is /auth/logout when creating a login then reset it back to / ensuring that the blank page is never displayed and the app correctly logs in.
1 parent 515a00a commit 1e645cd

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

packages/oauth/src/openshift/osoauth-service.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import $ from 'jquery'
44
import { OAuthProtoService } from '../api'
55
import { UserProfile, log } from '../globals'
66
import { CLUSTER_CONSOLE_KEY } from '../metadata'
7-
import { fetchPath, getCookie, isBlank, redirect } from '../utils'
7+
import { fetchPath, getCookie, isBlank, logoutUri, redirect } from '../utils'
88
import {
99
CLUSTER_VERSION_KEY,
1010
DEFAULT_CLUSTER_VERSION,
@@ -237,6 +237,11 @@ export class OSOAuthService implements OAuthProtoService {
237237
}
238238

239239
const currentURI = new URL(window.location.href)
240+
if (currentURI.pathname === logoutUri().pathname) {
241+
//Reset the logout path to the base path
242+
currentURI.pathname = currentURI.pathname.replace(logoutUri().pathname, '/')
243+
}
244+
240245
try {
241246
this.clearKeepAlive()
242247

packages/oauth/src/utils/urls.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@ async function logoutRedirectAvailable(): Promise<boolean> {
3838
return true
3939
}
4040

41+
export function logoutUri(): URL {
42+
return new URL(relToAbsUrl(LOGOUT_ENDPOINT))
43+
}
44+
4145
export function logoutRedirect(redirectUri: URL): void {
4246
// Have a logout page so append redirect uri to its url
43-
const logoutUri = new URL(relToAbsUrl(LOGOUT_ENDPOINT))
44-
logoutUri.searchParams.append('redirect_uri', redirectUri.toString())
47+
const targetUri = logoutUri()
48+
targetUri.searchParams.append('redirect_uri', redirectUri.toString())
4549

4650
logoutRedirectAvailable().then(exists => {
47-
if (exists) redirect(logoutUri)
51+
if (exists) redirect(targetUri)
4852
else redirect(redirectUri)
4953
})
5054
}

0 commit comments

Comments
 (0)