Add impersonate banner (#14734)

Related to https://github.com/twentyhq/twenty/pull/14360

<img width="1511" height="468" alt="Screenshot 2025-09-26 at 12 16 46"
src="https://github.com/user-attachments/assets/33e0e0b5-1226-455d-90f2-e4fc3deef7a8"
/>

@Bonapara, let you tell me if wording and banner color are ok. This
banner is displayed when a user is impersonating an other user
This commit is contained in:
Etienne
2025-09-29 17:10:46 +02:00
committed by GitHub
parent 462e2015b1
commit b74ed36ce3
4 changed files with 61 additions and 1 deletions
@@ -0,0 +1,24 @@
import { jwtDecode } from 'jwt-decode';
import { selector } from 'recoil';
import { isDefined } from 'twenty-shared/utils';
import { tokenPairState } from './tokenPairState';
export const isImpersonatingState = selector<boolean>({
key: 'isImpersonatingState',
get: ({ get }) => {
const tokenPair = get(tokenPairState);
if (!isDefined(tokenPair?.accessOrWorkspaceAgnosticToken?.token)) {
return false;
}
try {
const decodedToken = jwtDecode<{ isImpersonating: boolean }>(
tokenPair.accessOrWorkspaceAgnosticToken.token,
);
return decodedToken?.isImpersonating ?? false;
} catch {
return false;
}
},
});