user

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRepository

func NewRepository(dbExecutor db.DBTX, logger *zerolog.Logger) *repository

func Routes

func Routes(h *Handler, authMW *middle.AuthMiddleware) chi.Router

Types

type ChangePasswordRequest added in v0.1.2

type ChangePasswordRequest struct {
	CurrentPassword string `json:"current_password" validate:"required"`
	NewPassword     string `json:"new_password" validate:"required,min=8,max=72"`
	ConfirmPassword string `json:"confirm_password" validate:"required"`
}

type CreateUserCmd

type CreateUserCmd struct {
	Name         string
	Email        string
	PasswordHash string
	Role         string
}

type GetProfileResponse

type GetProfileResponse struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Email         string `json:"email"`
	MonitorsCount int32  `json:"monitors_count"`
	IsPaidUser    bool   `json:"is_paid_user"`
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(service *Service, validator *validator.Validate, logger *zerolog.Logger) *Handler

func (*Handler) ChangePassword added in v0.1.2

func (h *Handler) ChangePassword(w http.ResponseWriter, r *http.Request)

func (*Handler) GetProfile

func (h *Handler) GetProfile(w http.ResponseWriter, r *http.Request)

func (*Handler) LogIn

func (h *Handler) LogIn(w http.ResponseWriter, r *http.Request)

func (*Handler) Register

func (h *Handler) Register(w http.ResponseWriter, r *http.Request)

func (*Handler) SetupStatus added in v0.1.2

func (h *Handler) SetupStatus(w http.ResponseWriter, r *http.Request)

func (*Handler) UpdateProfile added in v0.1.2

func (h *Handler) UpdateProfile(w http.ResponseWriter, r *http.Request)

type LogInRequest

type LogInRequest struct {
	Email    string `json:"email" validate:"required,email"`
	Password string `json:"password" validate:"required"`
}

type LogInResponse

type LogInResponse struct {
	UserID      string `json:"user_id"`
	AccessToken string `json:"access_token"`
}

type LogInUserCmd

type LogInUserCmd struct {
	Email    string
	Password string
}

type LogInUserResult

type LogInUserResult struct {
	UserID      uuid.UUID
	AccessToken string
}

type RegisterRequest

type RegisterRequest struct {
	Name     string `json:"name" validate:"required,min=2,max=100"`
	Email    string `json:"email" validate:"required,email"`
	Password string `json:"password" validate:"required,min=8,max=72"`
}

type RegisterResponse

type RegisterResponse struct {
	UserID string `json:"user_id"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(repo *repository, tokenSvc *security.TokenService) *Service

func (*Service) ChangePassword added in v0.1.2

func (s *Service) ChangePassword(ctx context.Context, userID uuid.UUID, currentPw, newPw string) error

func (*Service) DecrementMonitorCount added in v0.1.2

func (s *Service) DecrementMonitorCount(ctx context.Context, userID uuid.UUID) error

func (*Service) GetProfile

func (s *Service) GetProfile(ctx context.Context, userId uuid.UUID) (User, error)

func (*Service) GetUserByID

func (s *Service) GetUserByID(ctx context.Context, userID uuid.UUID) (User, error)

func (*Service) IncrementMonitorCount

func (s *Service) IncrementMonitorCount(ctx context.Context, userID uuid.UUID) error

func (*Service) IsUserActive added in v0.1.2

func (s *Service) IsUserActive(ctx context.Context, userID uuid.UUID) (bool, error)

func (*Service) LogIn

func (s *Service) LogIn(ctx context.Context, data LogInUserCmd) (LogInUserResult, error)

func (*Service) Register

func (s *Service) Register(ctx context.Context, data CreateUserCmd) (uuid.UUID, error)

func (*Service) SetupStatus added in v0.1.2

func (s *Service) SetupStatus(ctx context.Context) (bool, error)

func (*Service) UpdateProfile added in v0.1.2

func (s *Service) UpdateProfile(ctx context.Context, userID uuid.UUID, name string) error

type SetupStatusResponse added in v0.1.2

type SetupStatusResponse struct {
	RegistrationsEnabled bool `json:"registrations_enabled"`
}

type UpdateProfileRequest added in v0.1.2

type UpdateProfileRequest struct {
	Name string `json:"name" validate:"required,min=2,max=100"`
}

type User

type User struct {
	ID            uuid.UUID
	Name          string
	Email         string
	PasswordHash  string
	Role          string
	IsActive      bool
	MonitorsCount int32
	IsPaidUser    bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL