store

package
v0.0.0-...-78d802f Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound  = errors.New("store: item not found")
	ErrConflict  = errors.New("store: item conflict")
	ErrCacheMiss = errors.New("cache: cache missed")
)

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	AccessUUID uuid.UUID `json:"access_uuid"`
	UserID     uuid.UUID `json:"user_id"`
}

type BaseModel

type BaseModel struct {
	ID        uuid.UUID    `json:"id"`
	CreatedAt sql.NullTime `json:"created_at"`
	UpdatedAt sql.NullTime `json:"updated_at"`
	DeletedAt sql.NullTime `json:"deleted_at"`
	Deleted   bool         `json:"deleted,omitempty"`
}

type CacheStore

type CacheStore interface {
	Token() TokenCacheStore
}

type Store

type Store interface {
	User() UserStore
}

type TokenCacheStore

type TokenCacheStore interface {
	Get(ad *AccessToken) (uuid.UUID, error)
	Set(id uuid.UUID, token *TokenDetails) error
	Delete(id uuid.UUID) (int64, error)
}

type TokenDetails

type TokenDetails struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	AccessUUID   uuid.UUID `json:"access_uuid"`
	RefreshUUID  uuid.UUID `json:"refresh_uuid"`
	AtExpires    int64     `json:"access_token_expires"`
	RtExpires    int64     `json:"refresh_token_expires"`
}

type User

type User struct {
	BaseModel
	Username     string
	Email        string
	PasswordHash string
	GivenName    string
	FamilyName   string
}

func (*User) SetPassword

func (u *User) SetPassword(password string) error

SetPassword takes in a password string, uses bcrypt to hash it and writes to the PasswordHash field

func (*User) ValidatePassword

func (u *User) ValidatePassword(password string) error

ValidatePassword takes in the password in string form and ensures it matches the hash

type UserStore

type UserStore interface {
	New(user *User) (string, error)
	Get() (*User, error)
	GetByID(id string) (*User, error)
	GetByUsername(username string) (*User, error)
	GetByEmail(email string) (*User, error)
	Update(user *User) (*User, error)
	Delete(id string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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