Documentation
¶
Index ¶
- Variables
- type Account
- func (a *Account) BasicAuthentication(password string) error
- func (a *Account) Get() error
- func (a *Account) Lock() error
- func (a *Account) NewJwtToken(audience string) (string, time.Time, error)
- func (a *Account) Save() error
- func (a *Account) Unlock() error
- func (a *Account) ValidJwtToken(rawToken, audience string) (bool, error)
- func (a *Account) WithContext(ctx *db.DatabaseContext)
- type BasicAuthMembership
- type ErrFieldInvalid
- type ErrFieldRequired
- type ErrInvalidLocation
- type ErrorStack
- type ErrorStackResults
- type Transmission
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
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 ¶
BasicAuthentication checks if the username and password are valid and returns the users account
func (*Account) NewJwtToken ¶
NewJwtToken generates a new token with the explicit audience.
func (*Account) ValidJwtToken ¶
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 ¶
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