Documentation
¶
Overview ¶
Package user provides user repository interfaces for domain persistence.
Index ¶
- Variables
- type Login
- type LoginResponse
- type Repository
- type Service
- type ServiceImpl
- func (s *ServiceImpl) Authenticate(ctx context.Context, email, password string) (*entities.User, error)
- func (s *ServiceImpl) DeleteUser(ctx context.Context, id string) error
- func (s *ServiceImpl) GetByID(ctx context.Context, id string) (*entities.User, error)
- func (s *ServiceImpl) GetUserByEmail(ctx context.Context, email string) (*entities.User, error)
- func (s *ServiceImpl) GetUserByID(ctx context.Context, id string) (*entities.User, error)
- func (s *ServiceImpl) ListUsers(ctx context.Context, offset, limit int) ([]*entities.User, error)
- func (s *ServiceImpl) Login(ctx context.Context, login *Login) (*LoginResponse, error)
- func (s *ServiceImpl) Logout(_ context.Context) error
- func (s *ServiceImpl) SignUp(ctx context.Context, signup *Signup) (*entities.User, error)
- func (s *ServiceImpl) UpdateUser(ctx context.Context, user *entities.User) error
- type Signup
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUserNotFound indicates that a user was not found ErrUserNotFound = domainerrors.New(domainerrors.ErrCodeNotFound, "user not found", nil) // ErrEmailAlreadyExists indicates that a user with the given email already exists ErrEmailAlreadyExists = domainerrors.New(domainerrors.ErrCodeAlreadyExists, "email already exists", nil) // ErrInvalidCredentials indicates that the provided credentials are invalid ErrInvalidCredentials = domainerrors.New(domainerrors.ErrCodeAuthentication, "invalid credentials", nil) // ErrUserExists indicates that a user with the given email already exists ErrUserExists = domainerrors.New(domainerrors.ErrCodeAlreadyExists, "user already exists", nil) )
Functions ¶
This section is empty.
Types ¶
type Login ¶
type Login struct {
Email string `json:"email" validate:"required,email"`
Password string `json:"password" validate:"required"`
}
Login represents a user login request
type LoginResponse ¶ added in v0.1.5
LoginResponse represents a user login response
type Repository ¶ added in v0.1.5
type Repository interface {
repository.Repository[*entities.User]
// GetByEmail gets a user by email
GetByEmail(ctx context.Context, email string) (*entities.User, error)
// GetByUsername gets a user by username
GetByUsername(ctx context.Context, username string) (*entities.User, error)
// GetByRole gets users by role
GetByRole(ctx context.Context, role string, offset, limit int) ([]*entities.User, error)
// GetActiveUsers gets all active users
GetActiveUsers(ctx context.Context, offset, limit int) ([]*entities.User, error)
// GetInactiveUsers gets all inactive users
GetInactiveUsers(ctx context.Context, offset, limit int) ([]*entities.User, error)
}
Repository defines the interface for user storage
type Service ¶
type Service interface {
SignUp(ctx context.Context, signup *Signup) (*entities.User, error)
Login(ctx context.Context, login *Login) (*LoginResponse, error)
Logout(ctx context.Context) error
GetUserByID(ctx context.Context, id string) (*entities.User, error)
GetUserByEmail(ctx context.Context, email string) (*entities.User, error)
UpdateUser(ctx context.Context, user *entities.User) error
DeleteUser(ctx context.Context, id string) error
ListUsers(ctx context.Context, offset, limit int) ([]*entities.User, error)
GetByID(ctx context.Context, id string) (*entities.User, error)
Authenticate(ctx context.Context, email, password string) (*entities.User, error)
}
Service defines the user service interface
func NewService ¶
func NewService(repo Repository, logger logging.Logger) Service
NewService creates a new user service
type ServiceImpl ¶
type ServiceImpl struct {
// contains filtered or unexported fields
}
ServiceImpl implements the Service interface
func (*ServiceImpl) Authenticate ¶ added in v0.1.5
func (s *ServiceImpl) Authenticate(ctx context.Context, email, password string) (*entities.User, error)
Authenticate matches the domain.UserService interface
func (*ServiceImpl) DeleteUser ¶
func (s *ServiceImpl) DeleteUser(ctx context.Context, id string) error
DeleteUser deletes a user
func (*ServiceImpl) GetUserByEmail ¶
GetUserByEmail retrieves a user by email
func (*ServiceImpl) GetUserByID ¶
GetUserByID retrieves a user by ID
func (*ServiceImpl) Login ¶
func (s *ServiceImpl) Login(ctx context.Context, login *Login) (*LoginResponse, error)
Login authenticates a user
func (*ServiceImpl) Logout ¶
func (s *ServiceImpl) Logout(_ context.Context) error
Logout handles user logout
func (*ServiceImpl) UpdateUser ¶
UpdateUser updates a user
Click to show internal directories.
Click to hide internal directories.