Skip to content

Commit

Permalink
Fix sonar reported issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aneelac22 committed Sep 11, 2024
1 parent 9d16ff1 commit 6acf10d
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions pkg/assets/static/redirectpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let keycloak;
let intervalRefRefresh;

export function handleSuccess(data) {
if (!data || !data.consoleURL || !data.defaultUserNamespace) {
if (!data?.consoleURL || !data?.defaultUserNamespace) {
window.location.href = consoleUrlMock;
return;
}
Expand All @@ -28,14 +28,14 @@ export function handleSuccess(data) {
let resultUrl;
if (data.status != "ready") {
resultUrl = consoleUrlMock;
}

if (link === "notebookController") {
resultUrl = `${baseUrl}notebookController/spawner`;
} else if (link === "dashboard") {
resultUrl = `${baseUrl}dashboard`;
} else {
if (link === "notebookController") {
resultUrl = `${baseUrl}notebookController/spawner`;
} else if (link === "dashboard") {
resultUrl = `${baseUrl}dashboard`;
} else {
resultUrl = redirectUrl.toString();
}
resultUrl = redirectUrl.toString();
}
const url = new URL(resultUrl);
Object.keys(params).forEach((key) => {
Expand Down Expand Up @@ -99,7 +99,7 @@ export function getJSON(
body = null,
headers = {}
) {
var xhr = new XMLHttpRequest();
let xhr = new XMLHttpRequest();
xhr.open(method, url, true);
if (token != null) xhr.setRequestHeader("Authorization", "Bearer " + token);

Expand All @@ -109,7 +109,7 @@ export function getJSON(

xhr.responseType = "json";
xhr.onload = () => {
var status = xhr.status;
let status = xhr.status;
if (status >= 200 && status < 300) {
callback(null, xhr.response);
} else {
Expand Down Expand Up @@ -142,9 +142,9 @@ function loadAuthLibrary(url, cbSuccess, cbError) {
export async function getRedirectData() {
const xhr = new XMLHttpRequest();

xhr.open('GET', registrationURL, true);
xhr.open("GET", registrationURL, true);

xhr.setRequestHeader('Authorization', `Bearer ${idToken}`);
xhr.setRequestHeader("Authorization", `Bearer ${idToken}`);
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status >= 200 && xhr.status < 300) {
Expand All @@ -158,7 +158,7 @@ export async function getRedirectData() {
handleError();
}
}
}
};
xhr.onerror = function () {
handleError();
};
Expand All @@ -177,7 +177,7 @@ export function redirectUser() {
const clientConfig = JSON.parse(data["auth-client-config"]);
initializeKeycloak(clientConfig);
},
handleError()
() => handleError()
);
}
});
Expand Down

0 comments on commit 6acf10d

Please sign in to comment.