user

package
v0.0.0-...-9ed9871 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 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 NewUser

type NewUser struct {
	Name            string      `json:"name" validate:"required"`
	Email           string      `json:"email" validate:"required,email"`
	Roles           []auth.Role `json:"roles" validate:"required"`
	Password        string      `json:"password" validate:"required"`
	PasswordConfirm string      `json:"password_confirm" validate:"eqfield=Password"`
}

type Store

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

func NewStore

func NewStore(log *zap.SugaredLogger, db *sqlx.DB) Store

func (Store) Authenticate

func (s Store) Authenticate(ctx context.Context, now time.Time, email string, password string) (auth.Claims, error)

func (Store) Create

func (s Store) Create(ctx context.Context, nu NewUser, now time.Time) (User, error)

func (Store) Delete

func (s Store) Delete(ctx context.Context, claims auth.Claims, userID string) error

func (Store) Query

func (s Store) Query(ctx context.Context, pageNumber int, rowsPerPage int) ([]User, error)

func (Store) QueryByEmail

func (s Store) QueryByEmail(ctx context.Context, claims auth.Claims, email string) (User, error)

func (Store) QueryByID

func (s Store) QueryByID(ctx context.Context, claims auth.Claims, userID string) (User, error)

func (Store) Update

func (s Store) Update(ctx context.Context, claims auth.Claims, userID string, uu UpdateUser, now time.Time) error

type UpdateUser

type UpdateUser struct {
	Name            *string     `json:"name"`
	Email           *string     `json:"email" validate:"omitempty,email"`
	Roles           []auth.Role `json:"roles"`
	Password        *string     `json:"password"`
	PasswordConfirm *string     `json:"password_confirm" validate:"omitempty,eqfield=Password"`
}

type User

type User struct {
	ID           string    `db:"user_id" json:"id"`
	Name         string    `db:"name" json:"name"`
	Email        string    `db:"email" json:"email"`
	Roles        string    `db:"roles" json:"roles"`
	PasswordHash []byte    `db:"password_hash" json:"-"`
	DateCreated  time.Time `db:"date_created" json:"date_created"`
	DateUpdated  time.Time `db:"date_updated" json:"date_updated"`
}

Jump to

Keyboard shortcuts

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