user

package
v0.0.0-...-b497eb9 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

type Repository interface {
	//GetOne(ctx context.Context, id uint) (User, error)
	GetByUsername(ctx context.Context, username string) (User, error)
	Create(ctx context.Context, user *User) error
	Update(ctx context.Context, id uint, user User) error
	Delete(ctx context.Context, id uint) error
}

Repository handle the CRUD operations with Users.

type User

type User struct {
	ID           uint      `json:"id,omitempty"`
	Username     string    `json:"username,omitempty"`
	Email        string    `json:"email,omitempty"`
	Location     string    `json:"location,omitempty"`
	GamesWon     int       `json:"games_won,omitempty"`
	GamesLost    int       `json:"games_lost,omitempty"`
	Password     string    `json:"password,omitempty"`
	PasswordHash string    `json:"-"`
	CreatedAt    time.Time `json:"created_at,omitempty"`
	UpdatedAt    time.Time `json:"updated_at,omitempty"`
}

User of the system.

func (*User) HashPassword

func (u *User) HashPassword() error

HashPassword generates a hash of the password and places the result in PasswordHash.

func (User) PasswordMatch

func (u User) PasswordMatch(password string) bool

PasswordMatch compares HashPassword with the password and returns true if they match.

Jump to

Keyboard shortcuts

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