account

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAuthenticationFailure occurs when an account attempts to authenticate but something goes wrong.
	ErrAuthenticationFailure = errors.New("Authentication failed")
)

Functions

func Authenticate

func Authenticate(ctx context.Context, db *sqlx.DB, now time.Time, name, password string) (auth.Claims, error)

Types

type Account

type Account struct {
	Id           string         `db:"id" json:"id"`
	Name         string         `db:"name" json:"name"`
	Roles        pq.StringArray `db:"roles" json:"roles"`
	PasswordHash []byte         `db:"password_hash" json:"-"`
	DateCreated  time.Time      `db:"date_created" json:"date_created"`
	DateUpdated  time.Time      `db:"date_updated" json:"date_updated"`
}

Account represents a thing with access to the system.

func Create

func Create(ctx context.Context, db *sqlx.DB, n NewAccount, now time.Time) (*Account, error)

Create inserts a new account into the database.

type NewAccount

type NewAccount struct {
	Name            string   `json:"name" validate:"required"`
	Roles           []string `json:"roles" validate:"required"`
	Password        string   `json:"password" validate:"required"`
	PasswordConfirm string   `json:"password_confirm" validate:"eqfield=Password"`
}

NewAccount contains information needed to create a new Account.

Jump to

Keyboard shortcuts

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