Documentation ¶
Index ¶
- Variables
- func EmailExists(db Database, a *Account) error
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(s int) (string, error)
- type Account
- type Database
- type PostgreSQL
- func (p *PostgreSQL) Close() error
- func (p *PostgreSQL) Confirm(token string) (*Account, error)
- func (p *PostgreSQL) Connect(conn string) error
- func (p *PostgreSQL) Create(a *Account, password string) error
- func (p *PostgreSQL) Delete(ID string) error
- func (p *PostgreSQL) GeneratePasswordToken(email string) (*Account, error)
- func (p *PostgreSQL) List(count32 int32, token string) (accounts []*Account, next_token string, err error)
- func (p *PostgreSQL) Migrate() error
- func (p *PostgreSQL) ReadByEmail(email string) (*Account, error)
- func (p *PostgreSQL) ReadByID(ID string) (*Account, error)
- func (p *PostgreSQL) Truncate() error
- func (p *PostgreSQL) Update(a *Account) error
- func (p *PostgreSQL) UpdatePassword(token, hashed_password string) (*Account, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAccountNotFound = errors.New("account not found") ErrEmailExists = errors.New("email already exists") ErrNoDatabase = errors.New("no database connection details") ErrNoPasswordGiven = errors.New("a password is required") )
View Source
var TOKEN_LENGTH = 32
Functions ¶
func EmailExists ¶
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomString ¶
GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
Types ¶
type Account ¶
type Account struct { ID string `db:"id"` Name string `validate:"required"` Email string `validate:"required"` HashedPassword string `db:"hashed_password"` ConfirmationToken string PasswordResetToken string Images []*image_service.Image Metadata map[string]string CreatedAt time.Time `db:"created_at"` }
func (*Account) ComparePasswordToHash ¶
func (*Account) HashPassword ¶
type Database ¶
type Database interface { List(count int32, token string) ([]*Account, string, error) ReadByID(ID string) (*Account, error) ReadByEmail(email string) (*Account, error) Create(a *Account, password string) error Update(a *Account) error Delete(ID string) error Confirm(token string) (*Account, error) GeneratePasswordToken(email string) (*Account, error) UpdatePassword(string, string) (*Account, error) Migrate() error Truncate() error Close() error }
func DatabaseFromEnv ¶
func DatabaseFromEnv() Database
type PostgreSQL ¶
type PostgreSQL struct { Database // contains filtered or unexported fields }
func (*PostgreSQL) Close ¶
func (p *PostgreSQL) Close() error
func (*PostgreSQL) Connect ¶
func (p *PostgreSQL) Connect(conn string) error
func (*PostgreSQL) Delete ¶
func (p *PostgreSQL) Delete(ID string) error
func (*PostgreSQL) GeneratePasswordToken ¶
func (p *PostgreSQL) GeneratePasswordToken(email string) (*Account, error)
func (*PostgreSQL) Migrate ¶
func (p *PostgreSQL) Migrate() error
func (*PostgreSQL) ReadByEmail ¶
func (p *PostgreSQL) ReadByEmail(email string) (*Account, error)
func (*PostgreSQL) Truncate ¶
func (p *PostgreSQL) Truncate() error
func (*PostgreSQL) Update ¶
func (p *PostgreSQL) Update(a *Account) error
func (*PostgreSQL) UpdatePassword ¶
func (p *PostgreSQL) UpdatePassword(token, hashed_password string) (*Account, error)
Click to show internal directories.
Click to hide internal directories.