29 lines
445 B
Go
29 lines
445 B
Go
package user
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"trankilou.fr/lassistanoque/backend/internal/domain"
|
|
)
|
|
|
|
type Service struct {
|
|
repo domain.UserRepository
|
|
}
|
|
|
|
func NewService(repo domain.UserRepository) *Service {
|
|
return &Service{
|
|
repo,
|
|
}
|
|
}
|
|
|
|
func (s *Service) GetUser(id string) (*domain.User, error) {
|
|
user, err := s.repo.FindUser(id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if !user.Enabled {
|
|
return nil, fmt.Errorf("unauthorized")
|
|
}
|
|
return user, nil
|
|
}
|