From 940ffac724894460af13e4e4a0de5e691e487c74 Mon Sep 17 00:00:00 2001 From: Guillaume Chervet Date: Sat, 3 Feb 2024 14:57:38 +0100 Subject: [PATCH] fix(oidc): json not valid add warning message (release) (#1258) --- packages/oidc-client/src/initSession.ts | 6 ++++++ packages/oidc-client/src/oidc.ts | 7 +++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/oidc-client/src/initSession.ts b/packages/oidc-client/src/initSession.ts index 3d79b69b3..f4a6e57e5 100644 --- a/packages/oidc-client/src/initSession.ts +++ b/packages/oidc-client/src/initSession.ts @@ -64,6 +64,12 @@ export const initSession = (configurationName, storage = sessionStorage) => { }; const getLoginParams = () => { const dataString = storage[`oidc.login.${configurationName}`]; + + if(!dataString){ + console.warn(`storage[oidc.login.${configurationName}] is empty`); + return null; + } + if (!getLoginParamsCache[configurationName]) { getLoginParamsCache[configurationName] = JSON.parse(dataString); } diff --git a/packages/oidc-client/src/oidc.ts b/packages/oidc-client/src/oidc.ts index 21add6cbc..c4143d5c4 100644 --- a/packages/oidc-client/src/oidc.ts +++ b/packages/oidc-client/src/oidc.ts @@ -234,8 +234,7 @@ Please checkout that you are using OIDC hook inside a { if (this.tryKeepExistingSessionPromise !== null) { return this.tryKeepExistingSessionPromise; - } - + } this.tryKeepExistingSessionPromise = tryKeepSessionAsync(this); return this.tryKeepExistingSessionPromise.then((result) => { this.tryKeepExistingSessionPromise = null; @@ -311,7 +310,7 @@ Please checkout that you are using OIDC hook inside a { + const silentLoginAsync = (extras: StringMap, state:string=null, scope:string = null) => { return _silentLoginAsync(this.configurationName, this.configuration, this.publishEvent.bind(this))(extras, state, scope); }; const localsilentLoginAsync = async () => { @@ -328,7 +327,7 @@ Please checkout that you are using OIDC hook inside a