Skip to content

The open alternative to Salesforce, designed for AI.

fix(front): stop impersonation from corrupting the impersonator's profile name (#21757)

Félix Malfaitecd90b78b973
diff --git a/packages/twenty-front/src/modules/auth/hooks/useImpersonationSession.ts b/packages/twenty-front/src/modules/auth/hooks/useImpersonationSession.ts
index 17dfd9cff35..89fb135d94f 100644
--- a/packages/twenty-front/src/modules/auth/hooks/useImpersonationSession.ts
+++ b/packages/twenty-front/src/modules/auth/hooks/useImpersonationSession.ts
@@ -3,6 +3,7 @@ import { useCallback } from 'react';
import { useAuth } from '@/auth/hooks/useAuth';
import { tokenPairState } from '@/auth/states/tokenPairState';
+import { clearSessionLocalStorageKeys } from '@/auth/utils/clearSessionLocalStorageKeys';
import { type AuthTokenPair } from '~/generated-metadata/graphql';
const IMPERSONATION_SESSION_KEY = 'impersonation_original_session';
@@ -47,6 +48,7 @@ export const useImpersonationSession = () => {
throw error;
}
+ clearSessionLocalStorageKeys();
reloadWithSession(targetPath);
},
[store, getAuthTokensFromLoginToken],
@@ -75,6 +77,7 @@ export const useImpersonationSession = () => {
sessionStorage.removeItem(IMPERSONATION_SESSION_KEY);
store.set(tokenPairState.atom, session.tokenPair);
+ clearSessionLocalStorageKeys();
reloadWithSession(session.returnPath);
}, [store, signOut]);
diff --git a/packages/twenty-front/src/pages/settings/profile/SettingsProfile.tsx b/packages/twenty-front/src/pages/settings/profile/SettingsProfile.tsx
index 840f858b709..b301f4b7111 100644
--- a/packages/twenty-front/src/pages/settings/profile/SettingsProfile.tsx
+++ b/packages/twenty-front/src/pages/settings/profile/SettingsProfile.tsx
@@ -57,7 +57,7 @@ export const SettingsProfile = () => {
title={t`Name`}
description={t`Your name as it will be displayed`}
/>
- <NameFields />
+ <NameFields key={currentWorkspaceMember.id} />
</Section>
<Section>
<H2Title