Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/utils/ConfigHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
localStorageKeys,
language as defaultLanguage,
} from '@/utils/defaults';
import ErrorHandler from '@/utils/ErrorHandler';
import { WarningInfoHandler } from '@/utils/ErrorHandler';
import ConfigSchema from '@/utils/ConfigSchema.json';

/* Given a page name, converts to lowercase, removes special characters and extension */
Expand Down Expand Up @@ -109,6 +109,6 @@ export const targetValidator = (target) => {
const acceptedTargets = ConfigSchema.properties.sections.items
.properties.items.items.properties.target.enum;
const isTargetValid = acceptedTargets.indexOf(target) !== -1;
if (!isTargetValid) ErrorHandler(`Unknown target value: ${target}`);
if (!isTargetValid) WarningInfoHandler(`Unknown target value: ${target}`);
return isTargetValid;
};
4 changes: 2 additions & 2 deletions src/utils/HeaderAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from 'axios';
import sha256 from 'crypto-js/sha256';
import ConfigAccumulator from '@/utils/ConfigAccumalator';
import { cookieKeys, localStorageKeys, serviceEndpoints } from '@/utils/defaults';
import { InfoHandler, ErrorHandler, InfoKeys } from '@/utils/ErrorHandler';
import { InfoHandler, ErrorHandler, InfoKeys, WarningInfoHandler } from '@/utils/ErrorHandler';
import { logout as authLogout } from '@/utils/Auth';

const getAppConfig = () => {
Expand Down Expand Up @@ -43,7 +43,7 @@ class HeaderAuth {
}
});
} catch (e) {
ErrorHandler('Error while trying to login using header authentication', e);
WarningInfoHandler('Error while trying to login using header authentication', e);
reject(e);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils/InitServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import yaml from 'js-yaml';
import { register } from 'register-service-worker';
import { sessionStorageKeys } from '@/utils/defaults';
import { statusMsg, statusErrorMsg } from '@/utils/CoolConsole';
import { WarningInfoHandler } from '@/utils/ErrorHandler';

/* Sets a local storage item with the state from the SW lifecycle */
const setSwStatus = (swStateToSet) => {
Expand Down Expand Up @@ -85,7 +86,7 @@ const registerServiceWorker = async () => {
},
error(error) {
setSwStatus({ error: true });
statusErrorMsg('Service Worker Status', 'Error during SW registration', error);
WarningInfoHandler('Error during SW registration', error);
},
});
}
Expand Down
9 changes: 6 additions & 3 deletions src/utils/KeycloakAuth.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Keycloak from 'keycloak-js';
import ConfigAccumulator from '@/utils/ConfigAccumalator';
import { localStorageKeys } from '@/utils/defaults';
import ErrorHandler from '@/utils/ErrorHandler';
import { WarningInfoHandler } from '@/utils/ErrorHandler';

const getAppConfig = () => {
const Accumulator = new ConfigAccumulator();
Expand Down Expand Up @@ -34,7 +34,10 @@ class KeycloakAuth {
return this.keycloakClient.login(this.loginOptions);
}
})
.catch((reason) => reject(reason));
.catch((reason) => {
WarningInfoHandler('Failed to authenticate with Keycloak', reason);
reject(reason);
});
});
}

Expand Down Expand Up @@ -89,7 +92,7 @@ export const initKeycloakAuth = () => {

export const getKeycloakAuth = () => {
if (!keycloak) {
ErrorHandler("Keycloak not initialized, can't get instance of class");
WarningInfoHandler("Keycloak not initialized, can't get instance of class");
}
return keycloak;
};
13 changes: 7 additions & 6 deletions src/utils/OidcAuth.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { UserManager, WebStorageStateStore } from 'oidc-client-ts';
import ConfigAccumulator from '@/utils/ConfigAccumalator';
import { localStorageKeys } from '@/utils/defaults';
import ErrorHandler from '@/utils/ErrorHandler';
import { statusMsg, statusErrorMsg } from '@/utils/CoolConsole';
import ErrorHandler, { WarningInfoHandler } from '@/utils/ErrorHandler';

const getAppConfig = () => {
const Accumulator = new ConfigAccumulator();
Expand Down Expand Up @@ -41,16 +40,18 @@ class OidcAuth {
const user = await this.userManager.getUser();

if (user === null) {
await this.userManager.signinRedirect();
try {
await this.userManager.signinRedirect();
} catch (e) {
WarningInfoHandler('Failed to authenticate with OIDC', e);
}
} else {
const { roles, groups } = user.profile;
const info = {
groups,
roles,
};

statusMsg(`user: ${user.profile.preferred_username}`, JSON.stringify(info));

localStorage.setItem(localStorageKeys.KEYCLOAK_INFO, JSON.stringify(info));
localStorage.setItem(localStorageKeys.USERNAME, user.profile.preferred_username);
}
Expand All @@ -63,7 +64,7 @@ class OidcAuth {
try {
await this.userManager.signoutRedirect();
} catch (reason) {
statusErrorMsg('logout', 'could not log out. Redirecting to OIDC instead', reason);
WarningInfoHandler('logout', 'could not log out. Redirecting to OIDC instead', reason);
window.location.href = this.userManager.settings.authority;
}
}
Expand Down