account

package
v0.0.0-...-095633c Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: Apache-2.0, Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyExists = errors.New("account already exists")
View Source
var ErrNotFound = errors.New("account not found")

Functions

This section is empty.

Types

type Account

type Account struct {
	Address    string
	Identities []Identity
}

type AuthMethod

type AuthMethod struct {
	Type  AuthMethodType
	Value string
}

type AuthMethodType

type AuthMethodType string
const (
	AuthMethodTypeAddress     AuthMethodType = "hcnet_address"
	AuthMethodTypePhoneNumber AuthMethodType = "phone_number"
	AuthMethodTypeEmail       AuthMethodType = "email"
)

func (AuthMethodType) Valid

func (t AuthMethodType) Valid() bool

type DBStore

type DBStore struct {
	DB *sqlx.DB
}

func (*DBStore) Add

func (s *DBStore) Add(a Account) error

func (*DBStore) Count

func (s *DBStore) Count() (int, error)

func (*DBStore) Delete

func (s *DBStore) Delete(address string) error

func (*DBStore) FindWithIdentityAddress

func (s *DBStore) FindWithIdentityAddress(address string) ([]Account, error)

func (*DBStore) FindWithIdentityAuthMethod

func (s *DBStore) FindWithIdentityAuthMethod(t AuthMethodType, value string) ([]Account, error)

func (*DBStore) FindWithIdentityEmail

func (s *DBStore) FindWithIdentityEmail(email string) ([]Account, error)

func (*DBStore) FindWithIdentityPhoneNumber

func (s *DBStore) FindWithIdentityPhoneNumber(phoneNumber string) ([]Account, error)

func (*DBStore) Get

func (s *DBStore) Get(address string) (Account, error)

func (*DBStore) Update

func (s *DBStore) Update(a Account) error

type Identity

type Identity struct {
	Role        string
	AuthMethods []AuthMethod
}

type Store

type Store interface {
	Add(a Account) error
	Delete(address string) error
	Get(address string) (Account, error)
	Update(a Account) error
	FindWithIdentityAddress(address string) ([]Account, error)
	FindWithIdentityPhoneNumber(phoneNumber string) ([]Account, error)
	FindWithIdentityEmail(email string) ([]Account, error)
	Count() (int, error)
}

Jump to

Keyboard shortcuts

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