forked from mtusi2026/mtusi2026lab3
feat: API replicas over HAProxy (3)
This commit is contained in:
@@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"unicode/utf8"
|
||||
@@ -49,6 +50,9 @@ func (s *UserService) Register(ctx context.Context, username, displayName, passw
|
||||
CreatedAt: now(),
|
||||
}
|
||||
if err := s.repo.CreateUser(ctx, u, hash); err != nil {
|
||||
if errors.Is(err, domain.ErrConflict) {
|
||||
return domain.User{}, fmt.Errorf("%w: username is already taken", domain.ErrConflict)
|
||||
}
|
||||
return domain.User{}, err
|
||||
}
|
||||
return u, nil
|
||||
|
||||
Reference in New Issue
Block a user