diff --git a/src/config.ts b/src/config.ts index a779754b..d63a38e8 100644 --- a/src/config.ts +++ b/src/config.ts @@ -35,7 +35,6 @@ declare global { config_INFORMATION_CONTROL_CONFIG: InformationControlConfig; config_DEFAULT_USER_LANGUAGE: string; config_INITIAL_USER_PROMPT: IntitialUserPrompt | null; - AUTH_REDIRECT_URL: string; } } @@ -51,7 +50,6 @@ const settings = { // The initial user prompt has been made because some customers want an // initial prompt to be displayed to the user when they first time visit the site. INITIAL_USER_PROMPT: window.config_INITIAL_USER_PROMPT, - AUTH_REDIRECT_URL: window.location.origin }; export default settings; diff --git a/src/index.tsx b/src/index.tsx index 516e64df..ce6a82bc 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -14,16 +14,19 @@ import { AuthWrapperProvider } from "./contexts/AuthWrapperContext"; const oidcConfig = { authority: `${Config.KEYCLOAK_URI}/realms/openftth`, client_id: "openftth-frontend", - redirect_uri: Config.AUTH_REDIRECT_URL, + redirect_uri: window.location.href, }; // This is used to clear the history after the sign-in redirect. const onSigninCallback = (_user: any | void): void => { - window.history.replaceState( - {}, - document.title, - window.location.pathname - ) + const url = new URL(window.location.href); + if (url.searchParams.has('state') && url.searchParams.has('session_state') && url.searchParams.has('iss') && url.searchParams.has('code')) { + url.searchParams.delete('state'); + url.searchParams.delete('session_state'); + url.searchParams.delete('iss'); + url.searchParams.delete('code'); + window.history.replaceState({}, '', url.toString()); + } } ReactDOM.render(