Skip to content

Commit

Permalink
now directs correctly preserving the original URI (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
runeanielsen authored Aug 19, 2024
1 parent a5d6f47 commit 037f337
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -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;
15 changes: 9 additions & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 037f337

Please sign in to comment.