user

package
v0.0.0-...-8241179 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyExists = errors.New("user already exists")

Functions

func ComparePasswordAndHash

func ComparePasswordAndHash(password, encodedHash string) (match bool, needsRehash bool, err error)

ComparePasswordAndHash verifies password against the PHC-style encoded hash. needsRehash == true if the stored hash uses weaker params than current defaults.

func HashPassword

func HashPassword(password string) (string, error)

HashPassword returns a PHC-style encoded argon2id string to store in DB.

Types

type Claims

type Claims struct {
	jwt.RegisteredClaims

	UserID id.ID `json:"userId"`
}

type Model

type Model struct {
	bun.BaseModel `bun:"table:user"`

	ID        id.ID     `bun:"id,pk"`
	Email     string    `bun:"email"`
	Password  string    `bun:"password"`
	CreatedAt time.Time `bun:"created_at"`
	UpdatedAt time.Time `bun:"updated_at"`
}

type Repository

type Repository interface {
	Create(ctx context.Context, model *Model) error
	GetByID(ctx context.Context, id id.ID) (*Model, bool, error)
	GetByEmail(ctx context.Context, email string) (*Model, bool, error)
}

func NewRepository

func NewRepository(tx db.Transaction) Repository

Jump to

Keyboard shortcuts

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