model

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2018 License: CC0-1.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPasswordDoesNotMatch is an error when a user inputs an invalid password
	ErrPasswordDoesNotMatch = errors.New("Password does not match")

	// ErrAccoundDoesNotExist is an error when a users account does not exist
	ErrAccoundDoesNotExist = errors.New("Account does not exist")

	// ErrDatastoreConnection is an error when a database connection cannot be made
	ErrDatastoreConnection = errors.New("Unable to connect to datastore")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	ID        int
	Username  string
	Firstname string
	Lastname  string
	Token     string
	TokenUsed bool
	Email     string
	Locked    bool
	// contains filtered or unexported fields
}

Account represents a user account

func (*Account) BasicAuthentication

func (a *Account) BasicAuthentication(password string) error

BasicAuthentication checks if the username and password are valid and returns the users account

func (*Account) Get

func (a *Account) Get() error

Get account from the database

func (*Account) Lock

func (a *Account) Lock() error

Lock will mark the account in a `locked` status.

func (*Account) NewJwtToken

func (a *Account) NewJwtToken(audience string) (string, time.Time, error)

NewJwtToken generates a new token with the explicit audience.

func (*Account) Save

func (a *Account) Save() error

Save a database entity

func (*Account) Unlock

func (a *Account) Unlock() error

Unlock will mark the account in an `unlocked` status.

func (*Account) ValidJwtToken

func (a *Account) ValidJwtToken(rawToken, audience string) (bool, error)

ValidJwtToken parses a token and determines if the token is valid

func (*Account) WithContext

func (a *Account) WithContext(ctx *db.DatabaseContext)

WithContext sets a db connection for a particular model

type BasicAuthMembership

type BasicAuthMembership struct {
	ID           int
	AccountID    int
	Account      *Account
	PasswordHash string
	Created      time.Time
	// contains filtered or unexported fields
}

BasicAuthMembership stores basic authentication information for the account.

func (*BasicAuthMembership) HashPassword

func (b *BasicAuthMembership) HashPassword(password string) error

HashPassword converts a plaintext password and generates a hash and updates the PasswordHash

func (*BasicAuthMembership) PasswordMatch

func (b *BasicAuthMembership) PasswordMatch(password string) bool

PasswordMatch determines if a plain text password matches its equivalent password hash

func (*BasicAuthMembership) WithContext

func (b *BasicAuthMembership) WithContext(ctx *db.DatabaseContext)

WithContext sets a db connection for a particular model

type ErrFieldInvalid

type ErrFieldInvalid struct {
	Message string
}

ErrFieldInvalid represents an error for a field with an invalid value

func (ErrFieldInvalid) Error

func (e ErrFieldInvalid) Error() string

Error returns the string representation of a Field Invalid error

func (ErrFieldInvalid) Result

func (e ErrFieldInvalid) Result(fieldname string) interface{}

Result creates a struct that is properly formatted for the client-side validation

type ErrFieldRequired

type ErrFieldRequired struct {
	Message string
}

ErrFieldRequired represents an error for a field that requires data

func (ErrFieldRequired) Error

func (e ErrFieldRequired) Error() string

Error is a basic represenation of a Require Field error

func (ErrFieldRequired) Result

func (e ErrFieldRequired) Result(fieldname string) interface{}

Result creates a struct that is properly formatted for the client-side validation

type ErrInvalidLocation

type ErrInvalidLocation struct {
	Message     string
	Suggestions []geo.Result
}

ErrInvalidLocation represents an error for location information with additional options

func (ErrInvalidLocation) Error

func (e ErrInvalidLocation) Error() string

Error returns the error message.

func (ErrInvalidLocation) Result

func (e ErrInvalidLocation) Result(fieldname string) interface{}

Result creates a struct that is properly formatted for the client-side validation

type ErrorStack

type ErrorStack []ErrorStackResults

ErrorStack contains a list of ErrorStackResults that have been captured

func NewErrorStack

func NewErrorStack(fieldname string, err error) ErrorStack

NewErrorStack creates a new stack of errors for a particular field

func (*ErrorStack) Append

func (stack *ErrorStack) Append(fieldname string, err error)

Append adds an error to the list of errors. For those that implement the ValidationResult interface, the return value for Result(fieldname) will be used to populate the stack. This is to properly format error/validation information that is to be returned to the client-side

func (ErrorStack) Error

func (stack ErrorStack) Error() string

Error is string representation of an ErrorStack and displays the total number of errors. This is to implement the error type

func (ErrorStack) HasErrors

func (stack ErrorStack) HasErrors() bool

HasErrors checks if any errors exist

func (ErrorStack) Result

func (stack ErrorStack) Result(fieldname string) interface{}

Result creates a struct that is properly formatted for the client-validation

type ErrorStackResults

type ErrorStackResults interface{}

ErrorStackResults is an interface to be used to represent a collection of interfaces. This currently has no additional methods

type Transmission

type Transmission struct {
	ID         int
	AccountID  int
	Raw        []byte
	RequestKey string
	AgencyKey  int
	Status     string
	Created    time.Time
	Modified   time.Time
}

Transmission record of application being sent to external system for additional processing.

func (*Transmission) Get

func (transmission *Transmission) Get(ctx *db.DatabaseContext) error

Get transmission record from the database.

func (*Transmission) Save

func (transmission *Transmission) Save(ctx *db.DatabaseContext) error

Save transmission record to the database.

type ValidationResult

type ValidationResult interface {
	Result(fieldname string) interface{}
}

ValidationResult is an interface to be used by errors that return a properly formatted struct to be used to send for client-side validation requests

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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