feat: update registration conflict exception to specify existing user role in error message

This commit is contained in:
pradeepkumar
2026-04-27 15:48:49 +05:30
parent fdbc727139
commit 4eda556059
2 changed files with 5 additions and 2 deletions

View File

@@ -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);
}

View File

@@ -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