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:
@@ -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;
|
||||
}
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user