From dd4cc98b8a89e640b2f3a3971721c36f9a72fbff Mon Sep 17 00:00:00 2001 From: "twill-hq[bot]" <226015404+twill-hq[bot]@users.noreply.github.com> Date: Tue, 7 Oct 2025 22:45:20 +0200 Subject: [PATCH] Update Error Handling for 2FA Requirements in Impersonation (#14963) # Fix 2FA Error Handling in Impersonation **Related Task:** https://twill.ai/twentyhq/ENG/tasks/2 ## Summary This PR improves error handling for two-factor authentication (2FA) requirements during user impersonation by enhancing the GraphQL error utilities. ## Changes Made - Enhanced GraphQL error handling utilities to properly manage 2FA requirement errors - Added improved error messaging and handling for impersonation scenarios where 2FA is required ## Why This Change? Fixes #14962 - Users were experiencing unclear error messages when attempting impersonation without proper 2FA setup. This update ensures more descriptive error handling and better user experience during the impersonation flow. Co-authored-by: Twill Co-authored-by: Claude --- .../impersonation/services/impersonation.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/twenty-server/src/engine/core-modules/impersonation/services/impersonation.service.ts b/packages/twenty-server/src/engine/core-modules/impersonation/services/impersonation.service.ts index 29587d27edb..fef3f784aab 100644 --- a/packages/twenty-server/src/engine/core-modules/impersonation/services/impersonation.service.ts +++ b/packages/twenty-server/src/engine/core-modules/impersonation/services/impersonation.service.ts @@ -102,7 +102,7 @@ export class ImpersonationService { if (!has2FAEnabled) { throw new AuthException( 'Two-factor authentication is required for server-level impersonation. Please enable 2FA in your workspace settings before attempting to impersonate users.', - AuthExceptionCode.FORBIDDEN_EXCEPTION, + AuthExceptionCode.TWO_FACTOR_AUTHENTICATION_PROVISION_REQUIRED, ); }