user

package
v0.0.0-...-2d74652 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRepository

func NewRepository(db *sqlx.DB) *repository

Types

type Handler

type Handler interface {
	Login(ctx *fiber.Ctx) error
}

func NewHandler

func NewHandler(service Service) Handler

type LoginRequest

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

type Service

type Service interface {
	GenerateToken(ctx *fiber.Ctx, req LoginRequest) (UserToken, error)
	Login(ctx *fiber.Ctx, req LoginRequest) (User, error)
	GetSession(ctx *fiber.Ctx) (UserSession, bool)
	GetUserSessionWithToken(ctx *fiber.Ctx, token string) (UserSession, error)
}

func NewService

func NewService(repo *repository) Service

type User

type User struct {
	ID        string    `gorm:"primaryKey;column:id"`
	Name      string    `db:"name"`
	Email     string    `db:"email"`
	Password  string    `db:"password"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

func (User) Columns

func (User) Columns() []string

func (User) TableName

func (User) TableName() string

type UserSession

type UserSession struct {
	User
	ExpiredAt time.Time
}

type UserToken

type UserToken struct {
	UserID    string    `db:"user_id"`
	Token     string    `db:"token"`
	ExpiredAt time.Time `db:"expired_at"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

func (UserToken) Columns

func (UserToken) Columns() []string

func (UserToken) TableName

func (UserToken) TableName() string

Jump to

Keyboard shortcuts

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