data

package
v0.0.0-...-a4c791e Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRecordNotFound     = errors.New("record not found")
	ErrEditConflict       = errors.New("edit conflict")
	ErrInvalidCredentials = errors.New("invalid credentials")
)
View Source
var (
	ErrDuplicateEmail   = errors.New("duplicate email")
	ErrDuplicatePhoneNo = errors.New("duplicate phone number")
)
View Source
var AnonymousUser = &User{}

Functions

func ValidateChangePassword

func ValidateChangePassword(v *validator.Validator, currentpassword, newpassword, confirmpassword string)

func ValidateEmail

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

func ValidatePasswordPlaintext

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

func ValidatePhoneNo

func ValidatePhoneNo(v *validator.Validator, phoneNo string)

func ValidateUser

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

Types

type Models

type Models struct {
	Users interface {
		Insert(user *User) error
	}
}

func NewModels

func NewModels(db *sql.DB) Models

type Password

type Password struct {
	Plaintext *string
	Confirm   string
	Hash      []byte
}

func (*Password) Matches

func (p *Password) Matches(plaintextPassword string) (bool, error)

func (*Password) Set

func (p *Password) Set(plaintextPassword, confirmPassword string) error

type User

type User struct {
	ID              int64     `json:"id"`
	CreatedAt       time.Time `json:"created_at"`
	FullName        string    `json:"full_name"`
	Username        string    `json:"username"`
	Email           string    `json:"email"`
	PhoneNo         string    `json:"phone_no"`
	Password        Password  `json:"-"`
	Activated       bool      `json:"activated"`
	Admin           bool      `json:"admin"`
	PhoneNoVerified bool      `json:"phone_no_verified"`
	Version         int       `json:"-"`
}

func (*User) IsAnonymous

func (u *User) IsAnonymous() bool

type UserModel

type UserModel struct {
	DB *sql.DB
}

func (UserModel) Insert

func (m UserModel) Insert(user *User) error

Jump to

Keyboard shortcuts

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