Skip to content

Commit

Permalink
fix(frontend): run ms oauth logout only when enabled (#123)
Browse files Browse the repository at this point in the history
This PR fixes a bug that run the MS oauth logic even when MS oauth was not enabled.

Fixes #119
  • Loading branch information
mawandm authored Jun 17, 2024
1 parent 26eed90 commit 8417fb8
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions nesis/frontend/client/src/SessionContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
Expand Down

0 comments on commit 8417fb8

Please sign in to comment.