From 8417fb809b830430716c16413680ed6da4d539ab Mon Sep 17 00:00:00 2001 From: Michael Sekamanya <86433807+mawandm@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:21:30 -0700 Subject: [PATCH] fix(frontend): run ms oauth logout only when enabled (#123) This PR fixes a bug that run the MS oauth logic even when MS oauth was not enabled. Fixes #119 --- nesis/frontend/client/src/SessionContext.js | 22 +++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/nesis/frontend/client/src/SessionContext.js b/nesis/frontend/client/src/SessionContext.js index 2425ae1..929da17 100644 --- a/nesis/frontend/client/src/SessionContext.js +++ b/nesis/frontend/client/src/SessionContext.js @@ -77,16 +77,18 @@ export function useSignOut(client, config) { async function logoutMicrosoft(config) { try { - const msalInstance = new PublicClientApplication({ - auth: { - clientId: config?.auth?.OAUTH_AZURE_CLIENT_ID, - authority: config?.auth?.OAUTH_AZURE_AUTHORITY, - redirectUri: config?.auth?.OAUTH_AZURE_REDIRECTURI, - postLogoutRedirectUri: config?.auth?.OAUTH_AZURE_REDIRECTURI, - }, - }); - await msalInstance.initialize(); - await msalInstance.logoutRedirect(); + if (config?.auth?.NESIS_OAUTH_AZURE_ENABLED) { + const msalInstance = new PublicClientApplication({ + auth: { + clientId: config?.auth?.OAUTH_AZURE_CLIENT_ID, + authority: config?.auth?.OAUTH_AZURE_AUTHORITY, + redirectUri: config?.auth?.OAUTH_AZURE_REDIRECTURI, + postLogoutRedirectUri: config?.auth?.OAUTH_AZURE_REDIRECTURI, + }, + }); + await msalInstance.initialize(); + await msalInstance.logoutRedirect(); + } } catch (e) { /* ignored */ }