feat: Added workspace-level impersonation module and functionality (#14360)
## Description - This PR is focused on issue https://github.com/twentyhq/core-team-issues/issues/1421 - Added workspace-level impersonation apart from current server-level-impersonation - Introduced WorkspaceImpersonationModule, including service and resolver for user impersonation within workspaces. - Enhanced AdminPanelService and AdminPanelResolver to support impersonation logic, including authentication checks and token generation. - added Member Management Interface in settings/members table - added GraphQL mutation for workspace-level impersonation ## Visual Proof <img width="919" height="444" alt="Screenshot 2025-09-09 at 1 29 22 AM" src="https://github.com/user-attachments/assets/a361c6eb-03de-48db-b68a-7d3a489fafde" /> https://github.com/user-attachments/assets/454bc1aa-8b8f-4de1-9304-7c147da71dd4 ## Impersontion Cookie <img width="1792" height="297" alt="Screenshot 2025-09-11 at 9 44 06 PM" src="https://github.com/user-attachments/assets/a8a37d5e-d38d-4472-94a7-4e4b36fba14e" /> <img width="1235" height="1041" alt="Screenshot 2025-09-19 at 1 24 09 AM" src="https://github.com/user-attachments/assets/875e8f9c-e0cb-404b-8291-8fadc6c2a163" /> --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com> Co-authored-by: Félix Malfait <felix@twenty.com> Co-authored-by: etiennejouan <jouan.etienne@gmail.com>
This commit is contained in:
@@ -1,16 +1,7 @@
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { type AuthTokenPair } from '~/generated/graphql';
|
||||
import { cookieStorage } from '~/utils/cookie-storage';
|
||||
|
||||
const isValidAuthTokenPair = (tokenPair: any): tokenPair is AuthTokenPair => {
|
||||
return (
|
||||
tokenPair &&
|
||||
typeof tokenPair === 'object' &&
|
||||
tokenPair.accessOrWorkspaceAgnosticToken &&
|
||||
typeof tokenPair.accessOrWorkspaceAgnosticToken === 'object' &&
|
||||
typeof tokenPair.accessOrWorkspaceAgnosticToken.token === 'string'
|
||||
);
|
||||
};
|
||||
import { isValidAuthTokenPair } from './isValidAuthTokenPair';
|
||||
|
||||
export const getTokenPair = (): AuthTokenPair | undefined => {
|
||||
const stringTokenPair = cookieStorage.getItem('tokenPair');
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { type AuthTokenPair } from '~/generated/graphql';
|
||||
|
||||
export const isValidAuthTokenPair = (
|
||||
tokenPair: any,
|
||||
): tokenPair is AuthTokenPair => {
|
||||
return (
|
||||
tokenPair &&
|
||||
typeof tokenPair === 'object' &&
|
||||
tokenPair.accessOrWorkspaceAgnosticToken &&
|
||||
typeof tokenPair.accessOrWorkspaceAgnosticToken === 'object' &&
|
||||
typeof tokenPair.accessOrWorkspaceAgnosticToken.token === 'string'
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user