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 <agent@twill.ai>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
twill-hq[bot]
2025-10-07 22:45:20 +02:00
committed by GitHub
co-authored by Twill Claude
parent 84f1559832
commit dd4cc98b8a
@@ -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,
);
}