Skip to content

Commit 0ef1621

Browse files
fix: [UIE-10253] - IAM Delegate: clear storage
1 parent d22474e commit 0ef1621

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

packages/manager/src/OAuth/oauth.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
} from '@linode/utilities';
66
import * as Sentry from '@sentry/react';
77

8-
import { clearUserInput, storage } from 'src/utilities/storage';
8+
import { clearStorage, clearUserInput, storage } from 'src/utilities/storage';
99

1010
import { getAppRoot, getClientId, getLoginURL } from './constants';
1111
import { generateCodeChallenge, generateCodeVerifier } from './pkce';
@@ -45,6 +45,7 @@ function clearNonceAndCodeVerifierFromLocalStorage() {
4545
function clearAllAuthDataFromLocalStorage() {
4646
clearNonceAndCodeVerifierFromLocalStorage();
4747
clearAuthDataFromLocalStorage();
48+
clearStorage('switch_account/company_name');
4849
}
4950

5051
export function clearStorageAndRedirectToLogout() {
@@ -105,6 +106,7 @@ export async function logout() {
105106

106107
clearUserInput();
107108
clearAuthDataFromLocalStorage();
109+
clearStorage('switch_account/company_name');
108110

109111
if (token) {
110112
const tokenWithoutPrefix = token.split(' ')[1];

packages/manager/src/features/Account/SwitchAccounts/useSwitchToParentAccount.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22

33
import { PARENT_USER_SESSION_EXPIRED } from 'src/features/Account/constants';
4-
import { setStorage } from 'src/utilities/storage';
4+
import { clearStorage, setStorage } from 'src/utilities/storage';
55

66
import { useParentChildAuthentication } from './useParentChildAuthentication';
77

@@ -38,7 +38,8 @@ export const useSwitchToParentAccount = ({
3838

3939
// Flag to prevent multiple clicks on the switch account button.
4040
setSubmitting(true);
41-
41+
// Clean up the company name in storage to prevent it from being used in the parent account after switching back from a child account.
42+
clearStorage('switch_account/company_name');
4243
try {
4344
// Revoke proxy or delegate token before switching to parent account.
4445
await revokeToken().catch(() => {

packages/manager/src/features/TopMenu/UserMenu/UserMenuPopover.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ export const UserMenuPopover = (props: UserMenuPopoverProps) => {
121121
}
122122
: undefined;
123123

124+
const switchAccountCompanyName = getStorage('switch_account/company_name');
124125
const companyNameOrEmail = getCompanyNameOrEmail({
125-
company: account?.company,
126+
company: account?.company ? account?.company : switchAccountCompanyName,
126127
profile,
127128
});
128129
const { data: parentProfile } = useProfile({ headers: proxyHeaders });

0 commit comments

Comments
 (0)