users

package
v0.0.0-...-e4c3b48 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PgUserRepository

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

func NewPgUserRepository

func NewPgUserRepository(db *pgxpool.Pool) *PgUserRepository

func (*PgUserRepository) Login

func (r *PgUserRepository) Login(ctx context.Context, user *UserLoginRequest) (string, error)

func (*PgUserRepository) Register

func (r *PgUserRepository) Register(ctx context.Context, user *UserRegistrationRequest) (int, error)

func (*PgUserRepository) ValidateSessionToken

func (r *PgUserRepository) ValidateSessionToken(ctx context.Context, sessionToken string) (int, error)

type User

type User struct {
	ID       int
	Username string
	Password string
}

type UserHandler

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

func NewUserHandler

func NewUserHandler(repo UserRepository) *UserHandler

func (*UserHandler) GetMe

func (h *UserHandler) GetMe(w http.ResponseWriter, r *http.Request)

func (*UserHandler) LoginUser

func (h *UserHandler) LoginUser(w http.ResponseWriter, r *http.Request)

func (*UserHandler) RegisterUser

func (h *UserHandler) RegisterUser(w http.ResponseWriter, r *http.Request)

type UserLoginErrorResponse

type UserLoginErrorResponse struct {
	ResponseType string `json:"response_type" validate:"required"`
	Message      string `json:"message" validate:"required"`
}

type UserLoginRequest

type UserLoginRequest struct {
	Username string `json:"username" validate:"required"`
	Password string `json:"password" validate:"required"`
}

type UserRegistrationErrorResponse

type UserRegistrationErrorResponse struct {
	ResponseType string `json:"response_type" validate:"required"`
	Message      string `json:"message" validate:"required"`
}

type UserRegistrationRequest

type UserRegistrationRequest struct {
	Username string `json:"username" validate:"required"`
	Password string `json:"password" validate:"required"`
}

type UserRegistrationSuccessResponse

type UserRegistrationSuccessResponse struct {
	ResponseType string `json:"response_type" validate:"required"`
	Message      string `json:"message" validate:"required"`
	UserID       int    `json:"user_id" validate:"required"`
}

type UserRepository

type UserRepository interface {
	Register(ctx context.Context, usRegReq *UserRegistrationRequest) (int, error)
	Login(ctx context.Context, usLogReq *UserLoginRequest) (string, error)
	ValidateSessionToken(ctx context.Context, sessionToken string) (int, error)
}

Jump to

Keyboard shortcuts

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