user

package
v0.0.0-...-0895a87 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

func NewHandler

func NewHandler(service Service) *Handler

func (*Handler) CreateUser

func (h *Handler) CreateUser(c *gin.Context)

func (*Handler) Login

func (h *Handler) Login(c *gin.Context)

func (*Handler) Logout

func (h *Handler) Logout(c *gin.Context)

type JWTCustomClaims

type JWTCustomClaims struct {
	jwt.RegisteredClaims
	UserID   int32  `json:"user_id"`
	Username string `json:"username"`
}

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type LoginResponse

type LoginResponse struct {
	Token     string       `json:"token"`
	User      UserResponse `json:"user"`
	ClientIP  string       `json:"client_ip"`
	UserAgent string       `json:"user_agent"`
}

type Repository

type Repository interface {
	CreateUser(context.Context, *UserRequest) (*UserResponse, error)
	GetUserByEmail(ctx context.Context, email string) (*sqlc.User, error)
}

func NewRepository

func NewRepository(q *sqlc.Queries) Repository

type Service

type Service interface {
	CreateUser(context.Context, *UserRequest) (*UserResponse, error)
	Login(context.Context, *LoginRequest) (*LoginResponse, error)
}

func NewService

func NewService(r Repository) Service

type UserRequest

type UserRequest struct {
	Name     string `json:"name"`
	Lastname string `json:"lastname"`
	Username string `json:"username"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

func (*UserRequest) Validate

func (ur *UserRequest) Validate() error

type UserResponse

type UserResponse struct {
	ID       int32  `json:"id"`
	Name     string `json:"name"`
	Lastname string `json:"lastname"`
	Username string `json:"username"`
	Email    string `json:"email"`
}

Jump to

Keyboard shortcuts

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