user

package
v0.0.1-0...-104a2d1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2025 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHTTPHandlers

func RegisterHTTPHandlers(cfg *config.Config, db *pgxpool.Pool, storage storage.Storage, validate *validation.Validator, tkn *jwt.Service, logger *zerolog.Logger) http.Handler

Types

type GetUserResponse

type GetUserResponse struct {
	CreatedAt      time.Time                          `json:"created_at"`
	UpdatedAt      time.Time                          `json:"updated_at"`
	FirstName      *string                            `json:"first_name"`
	LastName       *string                            `json:"last_name"`
	AvatarUrl      *string                            `json:"avatar_url"`
	Email          string                             `json:"email"`
	LinkedAccounts *[]repository.GetLinkedAccountsRow `json:"linked_accounts"`
	MfaEnabled     bool                               `json:"mfa_enabled"`
	HasPassword    bool                               `json:"has_password"`
}

type Handler

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

func NewHandler

func NewHandler(config *config.Config, validator *validation.Validator, repo Repository, storage storage.Storage, logger *zerolog.Logger) *Handler

func (*Handler) DeleteInfo

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

func (*Handler) GetInfo

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

func (*Handler) UpdateInfo

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

func (*Handler) UploadAvatar

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

UploadAvatar handles avatar image uploads

type Repository

type Repository interface {
	GetUserByEmail(ctx context.Context, email string) (repository.GetUserByEmailRow, error)
	GetUserByID(ctx context.Context, id uuid.UUID) (repository.GetUserByIdRow, error)
	CreateUser(ctx context.Context, params repository.CreateUserParams) (repository.User, error)
	CreateUserWithDefaults(ctx context.Context, params repository.CreateUserParams) (repository.User, error)
	FindORCreateOAuthUser(ctx context.Context, user goth.User, provider string) (repository.GetUserByEmailRow, error)
	UpdateUser(ctx context.Context, params repository.UpdateUserParams) (repository.User, error)
	DeleteUser(ctx context.Context, id uuid.UUID) error

	GetMFASecret(ctx context.Context, userID uuid.UUID) ([]byte, error)
	EnableMFA(ctx context.Context, id uuid.UUID) error
	StoreMFASecret(ctx context.Context, params repository.StoreMFASecretParams) error
	DisableMFA(ctx context.Context, userID uuid.UUID) error

	GetLinkedAccounts(ctx context.Context, id uuid.UUID) ([]repository.GetLinkedAccountsRow, error)
	AddLinkedAccounts(ctx context.Context, params repository.AddLinkedAccountParams) error
}

Repository defines the interface for user data operations

func NewRepository

func NewRepository(db *pgxpool.Pool, queries *repository.Queries, storage storage.Storage) Repository

NewRepository creates a new user repository

type UpdateUserRequest

type UpdateUserRequest struct {
	Email     string  `json:"email"`
	FirstName *string `json:"first_name"`
	LastName  *string `json:"last_name"`
	Password  *string `json:"password"`
}

Jump to

Keyboard shortcuts

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