feat: update registration conflict exception to specify existing user role in error message
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user