model

package
v0.0.0-...-6cd7fa8 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrNotFound          modelError = "model: resource not found"
	ErrIDInvalid         modelError = "model: ID provided was invalid"
	ErrPasswordInccorect modelError = "model: incorrect password provided"
	ErrEmailRequired     modelError = "model: email address is required"
	ErrEmailInvalid      modelError = "model: email address is not valid"
	ErrEmailTaken        modelError = "model: email address is already taken"
	ErrPasswordTooShort  modelError = "model: password must be at least 8 characters long"
	ErrPasswordRequired  modelError = "model: password is required"
	ErrRememberRequited  modelError = "model: remember token is required"
	ErrRememberTooShort  modelError = "model: remember token must be at least 32 bytes long"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type User

type User struct {
	gorm.Model
	Name         string
	Email        string `gorm:"not null;unique_index"`
	Password     string `gorm:"-"`
	PasswordHash string `gorm:"not null"`
	Remember     string `gorm:"-"`
	RememberHash string `gorm:"not null;unique_index"`
}

user db representation

type UserDB

type UserDB interface {
	// db look ups with args
	ByID(id uint) (*User, error)
	ByEmail(email string) (*User, error)
	ByRemember(token string) (*User, error)

	// altering db data
	Create(user *User) error
	Update(user *User) error
	Delete(id uint) error

	// db operations
	Close() error
	AutoMigrate() error
	DestructiveReset() error
}

type UserService

type UserService interface {
	Authenticate(email string, password string) (*User, error)
	UserDB
}

func NewUserService

func NewUserService(connInfo string) (UserService, error)

Jump to

Keyboard shortcuts

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