repository

package
v0.0.0-...-3eb4ebe Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateEmail = errors.New("duplicate email")
	ErrRecordNotFound = errors.New("record not found")
)
View Source
var AnonymousUser = &User{}

Functions

func ValidateEmail

func ValidateEmail(v *validator.Validator, email string)

ValidateEmail rules the email validation

func ValidatePassword

func ValidatePassword(v *validator.Validator, password string)

ValidatePassword rules the password validation

func ValidateUser

func ValidateUser(v *validator.Validator, u *User)

ValidateUser rules the password and email validations

Types

type AccountRepository

type AccountRepository interface {
	CreateUser(ctx context.Context, user *User) error
	GetUser(ctx context.Context, email string) (*User, error)
	ServiceStatus(ctx context.Context) error
}

func NewAccountRepository

func NewAccountRepository(conn database.Connection) AccountRepository

type User

type User struct {
	UserID       uint64 `json:"user_id"`
	Email        string `json:"email"`
	Password     string `json:"password"`
	PasswordHash []byte `json:"-"`
}

func (*User) IsAnonymous

func (u *User) IsAnonymous() bool

func (*User) Matches

func (u *User) Matches(plaintextPassword string) (bool, error)

Matches compare the plain-text password and hashed version

func (*User) Set

func (u *User) Set(plaintextPassword string) error

Set hashes plain-text password

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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