forked from mtusi2026/mtusi2026lab6
feat(lab6): add observability and SLO burn-rate alerts
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"mtusi2026lab6/internal/domain"
|
||||
"mtusi2026lab6/internal/security"
|
||||
)
|
||||
|
||||
func (s *Service) CreateUser(ctx context.Context, command CreateUserCommand) (domain.User, error) {
|
||||
if err := domain.ValidateUser(command.Username, command.DisplayName); err != nil {
|
||||
return domain.User{}, fmt.Errorf("%w: %v", ErrInvalidInput, err)
|
||||
}
|
||||
if err := security.ValidatePassword(command.Password); err != nil {
|
||||
return domain.User{}, fmt.Errorf("%w: %v", ErrInvalidInput, err)
|
||||
}
|
||||
|
||||
passwordHash, err := security.HashPassword(command.Password)
|
||||
if err != nil {
|
||||
return domain.User{}, fmt.Errorf("hash password: %w", err)
|
||||
}
|
||||
return s.repository.CreateUser(
|
||||
ctx,
|
||||
command.Username,
|
||||
command.DisplayName,
|
||||
passwordHash,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user