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

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

No files matched your search

+1 -1
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);
}
+4 -1
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