users

package
v0.0.0-...-4676a12 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountData

type AccountData struct {
	Id    Id
	Name  string
	Email string
	Token string
}

func NewUserData

func NewUserData(id Id, name string, email string, token string) AccountData

func ToUserData

func ToUserData(user User) AccountData

func (AccountData) String

func (d AccountData) String() string

type Id

type Id int64
const InvalidId Id = -1

func IdsExcept

func IdsExcept(users []Id, except Id) []Id

func ParseId

func ParseId(idStr string) (Id, error)

func (Id) String

func (t Id) String() string

type MemoryUserDb

type MemoryUserDb struct {
	// contains filtered or unexported fields
}

func NewMemoryUserDb

func NewMemoryUserDb() *MemoryUserDb

func (*MemoryUserDb) Add

func (m *MemoryUserDb) Add(email string, password string, name string) (AccountData, error)

func (*MemoryUserDb) Authenticate

func (m *MemoryUserDb) Authenticate(email string, password string) (AccountData, error)

func (*MemoryUserDb) ChangeName

func (m *MemoryUserDb) ChangeName(id Id, newName string) error

func (*MemoryUserDb) GetData

func (m *MemoryUserDb) GetData(id Id) (AccountData, error)

func (*MemoryUserDb) ListIds

func (m *MemoryUserDb) ListIds() ([]Id, error)

func (*MemoryUserDb) VerifyToken

func (m *MemoryUserDb) VerifyToken(token string) (AccountData, error)

type SqlUserDatabase

type SqlUserDatabase struct {
	// contains filtered or unexported fields
}

func NewSqlUserDatabase

func NewSqlUserDatabase(filename string) (*SqlUserDatabase, error)

func (*SqlUserDatabase) Add

func (s *SqlUserDatabase) Add(email string, password string, name string) (user AccountData, err error)

func (*SqlUserDatabase) Authenticate

func (s *SqlUserDatabase) Authenticate(email string, password string) (user AccountData, err error)

func (*SqlUserDatabase) ChangeName

func (s *SqlUserDatabase) ChangeName(id Id, newName string) error

func (*SqlUserDatabase) ChangePassword

func (s *SqlUserDatabase) ChangePassword(id Id, newPassword string) error

func (*SqlUserDatabase) Close

func (s *SqlUserDatabase) Close() error

func (*SqlUserDatabase) FindByEmail

func (s *SqlUserDatabase) FindByEmail(email string) (data AccountData, err error)

func (*SqlUserDatabase) GetData

func (s *SqlUserDatabase) GetData(id Id) (data AccountData, err error)

func (*SqlUserDatabase) ListIds

func (s *SqlUserDatabase) ListIds() ([]Id, error)

func (*SqlUserDatabase) VerifyToken

func (s *SqlUserDatabase) VerifyToken(token string) (user AccountData, err error)

type User

type User struct {
	Id           Id
	Email        string
	Name         string
	PasswordHash string
}

func NewUser

func NewUser(id Id, email string, name string, passwordHash string) *User

type Users

type Users interface {
	Add(email string, password string, name string) (AccountData, error)
	ListIds() ([]Id, error)
	GetData(id Id) (AccountData, error)
	ChangeName(id Id, newName string) error
	ChangePassword(id Id, newPassword string) error
	VerifyToken(token string) (AccountData, error)
	Authenticate(email string, password string) (AccountData, error)
}

Jump to

Keyboard shortcuts

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