account

package
v0.0.0-...-0ebd481 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: MIT Imports: 10 Imported by: 0

README

Account

The Account is a model level abstraction that represents a user.

Documentation

Index

Constants

View Source
const TableName = "account"

TableName defines the data store table name to use when storing information of the Account abstraction

Variables

This section is empty.

Functions

func MigrateMySQLTable

func MigrateMySQLTable(connection *sql.DB) []error

Types

type Account

type Account interface {
	GetDatabaseID() uint64
	GetUUID() string
	GetUsername() string
	GetEmail() string
	GetHashedPassword() string
	GetLastUpdated() time.Time
	GetCreatedOn() time.Time

	SetPassword(string) error
	SetUsername(string) error
	SetEmail(string) error

	Create() error
	LoadEmail(string) error
	LoadUsername(string) error
	LoadUUID(string) error
	Update() error

	JSON() []byte
}

Account defines a user's primary account

func NewMySQLAccount

func NewMySQLAccount(connection *sql.DB) Account

NewMySQLAccount creates a new Account interface

type MySQL

type MySQL struct {
	ID          uint64    `json:"id"`
	UUID        string    `json:"uuid"`
	Email       string    `json:"email"`
	Username    string    `json:"username"`
	Password    string    `json:"password"`
	CreatedOn   time.Time `json:"created_on"`
	LastUpdated time.Time `json:"last_updated"`
	// contains filtered or unexported fields
}

MySQL defines an implementation for the Account interface that includes methods to interact with a MySQL data store

func (*MySQL) Create

func (a *MySQL) Create() error

Create inserts the account into the data store and populates this instance with the generated ID and UUID

func (MySQL) GetCreatedOn

func (a MySQL) GetCreatedOn() time.Time

GetCreatedOn complies to the Account interface

func (MySQL) GetDatabaseID

func (a MySQL) GetDatabaseID() uint64

GetDatabaseID complies to the Account interface

func (MySQL) GetEmail

func (a MySQL) GetEmail() string

GetEmail complies to the Account interface

func (MySQL) GetHashedPassword

func (a MySQL) GetHashedPassword() string

GetHashedPassword complies to the Account interface

func (MySQL) GetLastUpdated

func (a MySQL) GetLastUpdated() time.Time

GetLastUpdated complies to the Account interface

func (MySQL) GetUUID

func (a MySQL) GetUUID() string

GetUUID complies to the Account interface

func (MySQL) GetUsername

func (a MySQL) GetUsername() string

GetUsername complies to the Account interface

func (MySQL) JSON

func (a MySQL) JSON() []byte

JSON returns the JSON representation of this account instance

func (*MySQL) LoadEmail

func (a *MySQL) LoadEmail(email string) error

LoadEmail loads the user based on the provided email :email

func (*MySQL) LoadUUID

func (a *MySQL) LoadUUID(uuid string) error

LoadUUID loads the user based on the provided UUID :uuid

func (*MySQL) LoadUsername

func (a *MySQL) LoadUsername(username string) error

LoadUsername loads the user based on the provided username :username

func (*MySQL) SetEmail

func (a *MySQL) SetEmail(email string) error

SetEmail sets the Email property of the account instance and is needed to comply to the Account interface

func (*MySQL) SetPassword

func (a *MySQL) SetPassword(plaintext string) error

SetPassword sets the Password property to a string that contains a hash and it's corresponding salt, and is required to comply with the Account interface

func (*MySQL) SetUsername

func (a *MySQL) SetUsername(username string) error

SetUsername sets the Username property of the account instance and is needed to comply to the Account interface

func (*MySQL) Update

func (a *MySQL) Update() error

Update updates the data store with data from this account instance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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