From 4eda556059c8607f9bb3f41a10604b11142a2233 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Mon, 27 Apr 2026 15:48:49 +0530 Subject: [PATCH] feat: update registration conflict exception to specify existing user role in error message --- src/auth/auth.controller.ts | 2 +- src/auth/auth.service.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 5879637..3cfebc3 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -77,7 +77,7 @@ export class AuthController { }, }) @ApiResponse({ status: 400, description: 'Validation error' }) - @ApiResponse({ status: 409, description: 'Email already registered' }) + @ApiResponse({ status: 409, description: 'Email address is already registered as an agent or user' }) async register(@Body() dto: RegisterDto) { return this.authService.register(dto); } diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 55cff62..c9ed375 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -65,7 +65,10 @@ export class AuthService { }); if (existingUser) { - throw new ConflictException('Email already registered'); + const existingRoleLabel = existingUser.role === UserRole.AGENT ? 'agent' : 'user'; + throw new ConflictException( + `Email address is already registered as an ${existingRoleLabel}. Kindly use a different email address for the new signup.`, + ); } // Hash password