Skip to content

Commit

Permalink
fix: readonlyMode : add extraQueryParams
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentC35 committed Oct 24, 2023
1 parent 83ef9be commit 71c1915
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/utils/auth/oidcClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const createOidcClient = async ({
evtUserActivity,
urlPortail,
}) => {
const isReadOnlyMode = window.location.pathname.startsWith(`/${READ_ONLY}`);
const configHash = fnv1aHashToHex(`${url} ${realm} ${clientId}`);
const configHashKey = 'configHash';

Expand All @@ -31,23 +32,17 @@ export const createOidcClient = async ({
});

const login = async () => {
let { newUrl: redirect_uri } = addParamToUrl({
const { newUrl: redirect_uri } = addParamToUrl({
url: window.location.href,
name: configHashKey,
value: configHash,
});

if (window.location.pathname.startsWith(`/${READ_ONLY}`)) {
const { newUrl } = addParamToUrl({
url: redirect_uri,
name: 'kc_idp_hint',
value: identityProvider,
});
redirect_uri = newUrl;
}

await userManager.signinRedirect({
redirect_uri,
extraQueryParams: isReadOnlyMode
? { kc_idp_hint: identityProvider }
: null,
redirectMethod: 'replace',
});
return new Promise(() => {});
Expand Down

0 comments on commit 71c1915

Please sign in to comment.