From 7e3e97f6da839b936d33ec492b914804fa6cbfb8 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Tue, 10 Oct 2023 15:34:10 +0200 Subject: [PATCH] Refactor oidc adapter --- web/src/core/adapters/oidc/oidc.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/web/src/core/adapters/oidc/oidc.ts b/web/src/core/adapters/oidc/oidc.ts index b97a23e2c..b9b7dfbb7 100644 --- a/web/src/core/adapters/oidc/oidc.ts +++ b/web/src/core/adapters/oidc/oidc.ts @@ -87,20 +87,12 @@ export async function createOidc(params: { url = result.newUrl; } - const names = ["code", "state", "session_state"]; - let dummyUrl = "https://dummy.com"; - for (const name of names) { + for (const name of ["code", "state", "session_state"]) { const result = retrieveParamFromUrl({ name, url }); - if (!result.wasPresent) { - if (names.indexOf(name) === 0) { - break read_successful_login_query_params; - } else { - assert(false); - } - } + assert(result.wasPresent); dummyUrl = addParamToUrl({ "url": dummyUrl, @@ -111,9 +103,10 @@ export async function createOidc(params: { url = result.newUrl; } - await userManager.signinRedirectCallback(dummyUrl); - + // NOTE: Remove the query params from the url window.history.pushState(null, "", url); + + await userManager.signinRedirectCallback(dummyUrl); } let currentAccessToken = (await userManager.getUser())?.access_token ?? "";