-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbody.html
55 lines (47 loc) · 1.49 KB
/
body.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<script>
function oidcRedirect() {
const qs = new URLSearchParams(window.location.search.substring(1));
qs.delete("oidc");
const path = encodeURIComponent(
window.location.pathname.replace(/\/+/g, "/"),
);
const search = encodeURIComponent(qs.toString());
let hash = "config.prejoinConfig.enabled=false";
if (window.location.hash) {
hash = `${hash}&${window.location.hash.substring(1)}`;
}
hash = encodeURIComponent(hash);
window.location = `/oidc/auth?path=${path}&search=${search}&hash=${hash}`;
try {
// remove react from DOM to prevent UI distortion
document.all.react.remove();
} catch {
// do nothing
}
}
function interceptLoginRequest() {
try {
// check if login or IamHost button is created in DOM
const _button = document.getElementById("modal-dialog-ok-button");
if (!_button) return;
let labelKey;
try {
labelKey = Object.values(_button)[0].return.memoizedProps.labelKey;
} catch {
// do nothing
}
if (labelKey === "dialog.login") {
// if this is a login screen, redirect to OIDC login page
oidcRedirect();
} else if (labelKey === "dialog.IamHost") {
// if this is an IamHost screen, redirect to OIDC login page when clicked
_button.onclick = oidcRedirect;
}
} finally {
setTimeout(function () {
interceptLoginRequest();
}, 1000);
}
}
interceptLoginRequest();
</script>