correctly clear scope

This commit is contained in:
Stanislav Deviatykh 2025-10-22 00:09:57 +03:00
commit eb76696d97
2 changed files with 11 additions and 3 deletions

View file

@ -122,6 +122,11 @@ export const saveScopeToSessionStorage = (
}
};
export const clearScopeFromSessionStorage = (serverUrl: string) => {
const key = getServerSpecificKey(SESSION_KEYS.SCOPE, serverUrl);
sessionStorage.removeItem(key);
};
export class InspectorOAuthClientProvider implements OAuthClientProvider {
constructor(protected serverUrl: string) {
// Save the server URL to session storage
@ -243,9 +248,6 @@ export class InspectorOAuthClientProvider implements OAuthClientProvider {
sessionStorage.removeItem(
getServerSpecificKey(SESSION_KEYS.CODE_VERIFIER, this.serverUrl),
);
sessionStorage.removeItem(
getServerSpecificKey(SESSION_KEYS.SCOPE, this.serverUrl),
);
}
}

View file

@ -46,6 +46,7 @@ import {
InspectorOAuthClientProvider,
saveClientInformationToSessionStorage,
saveScopeToSessionStorage,
clearScopeFromSessionStorage,
discoverScopes,
} from "../auth";
import {
@ -144,6 +145,11 @@ export function useConnection({
}, [oauthClientId, oauthClientSecret, sseUrl]);
useEffect(() => {
if (!oauthScope) {
clearScopeFromSessionStorage(sseUrl);
return;
}
saveScopeToSessionStorage(sseUrl, oauthScope);
}, [oauthScope, sseUrl]);