-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add static redirect page to sso and then to requested page
[RHCLOUD-32115]
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" class="pf-m-redhat-font"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title>OpenShift Developer Sandbox</title> | ||
</head> | ||
<body> | ||
</body> | ||
<script src="landingpage.js"></script> | ||
<script src="redirectpage.js"></script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const queryString = window.location.search; | ||
const urlParams = new URLSearchParams(queryString); | ||
const link = urlParams.get("link"); | ||
const keyword = urlParams.get("keyword"); | ||
const selectedId = urlParams.get("selectedId"); | ||
const consoleUrl = "https://console.redhat.com/openshift/sandbox"; | ||
const baseUrl = `https://${data.consoleURL}/`; | ||
const appendedUrl = `${link}/ns/${data.defaultUserNamespace}`; | ||
const params = { | ||
keyword, | ||
selectedId, | ||
}; | ||
const redirectUrl = new URL(baseUrl + appendedUrl); | ||
|
||
Object.keys(params).forEach((key) => { | ||
if (params[key]) { | ||
urlParams.searchParams.append(key, params[key]); | ||
} | ||
}); | ||
|
||
function handleSuccess(data) { | ||
if (data.status != "ready") { | ||
window.location.href = "https://console.redhat.com/openshift/sandbox"; | ||
} else { | ||
window.location.href = | ||
link === "notebookController" | ||
? `${baseUrl}notebookController/spawner` | ||
: link === "dashboard" | ||
? `${baseUrl}dashboard` | ||
: redirectUrl.toString(); | ||
} | ||
} | ||
|
||
function handleError() { | ||
window.location.href = "https://console.redhat.com/openshift/sandbox"; | ||
} | ||
|
||
if (keycloak) { | ||
fetch( | ||
"registration-service-toolchain-host-operator.apps.sandbox.x8i5.p1.openshiftapps.com/api/v1/signup", | ||
{ | ||
method: "GET", | ||
headers: { | ||
Authorization: "Bearer" + keycloak.token, | ||
}, | ||
} | ||
) | ||
.then((response) => response.json()) | ||
.then((data) => handleSuccess(data)) | ||
.catch((error) => handleError(error)); | ||
} else { | ||
login(); | ||
} |