Add username existence check in customer registration and update handlers
This commit is contained in:
@@ -89,6 +89,12 @@ func (s *customerService) Register(ctx context.Context, form *CreateCustomerForm
|
||||
return nil, errors.New("customer with this email already exists")
|
||||
}
|
||||
|
||||
// Check if username already exists
|
||||
existingCustomer, _ = s.repository.GetByUsername(ctx, strings.ToLower(form.Username))
|
||||
if existingCustomer != nil {
|
||||
return nil, errors.New("customer with this username already exists")
|
||||
}
|
||||
|
||||
// Check validator
|
||||
if !s.validator.IsValidUsername(form.Username) {
|
||||
return nil, errors.New("invalid username format")
|
||||
|
||||
Reference in New Issue
Block a user