lab2
Application / Lint (pull_request) Canceled after 0s
Application / Unit tests (pull_request) Canceled after 0s
Application / Docker build (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
Vladislav Kunetskiy
2026-10-06 00:19:15 +03:00
parent 51b236a69f
commit 5ea57db639
119 changed files with 9935 additions and 2138 deletions
+12 -4
View File
@@ -7,12 +7,11 @@ import (
"github.com/google/uuid"
"mtusi-messenger/internal/domain"
"mtusi-messenger/internal/platform/password"
)
//go:generate go tool mockery
type Repository interface {
Create(ctx context.Context, draft domain.UserDraft) (domain.User, error)
Create(ctx context.Context, draft domain.NewUser) (domain.User, error)
GetByID(ctx context.Context, id uuid.UUID) (domain.User, error)
}
@@ -29,7 +28,16 @@ func (s *Service) Register(ctx context.Context, draft domain.UserDraft) (domain.
return domain.User{}, err
}
user, err := s.users.Create(ctx, draft)
hash, err := password.Hash(draft.Password)
if err != nil {
return domain.User{}, fmt.Errorf("hash password: %w", err)
}
user, err := s.users.Create(ctx, domain.NewUser{
Username: draft.Username,
DisplayName: draft.DisplayName,
PasswordHash: hash,
})
if err != nil {
return domain.User{}, fmt.Errorf("create user: %w", err)
}