Documentation ¶
Overview ¶
Package models provides the backing data models for the Phi Mu Alpha Sinfonia - Delta Iota chapter website.
Index ¶
- Variables
- type EmptyFieldError
- type InvalidFieldError
- type Notification
- type Session
- type User
- func (u *User) CopyFrom(user *User)
- func (u *User) NewSession(expire time.Time) (*Session, error)
- func (u *User) SQLReadFields() []interface{}
- func (u *User) SQLWriteFields() []interface{}
- func (u *User) SetPassword(password string) error
- func (u *User) TryPassword(password string) error
- func (u *User) Validate() error
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidPassword is returned when password authentication fails for a // specified User. ErrInvalidPassword = errors.New("invalid password") )
Functions ¶
This section is empty.
Types ¶
type EmptyFieldError ¶
type EmptyFieldError struct {
Field string
}
EmptyFieldError is returned when a field fails a call to Validate due to empty input data.
The struct contains the name of the field which failed.
func (*EmptyFieldError) Error ¶
func (e *EmptyFieldError) Error() string
Error returns a string representation of an EmptyFieldError.
type InvalidFieldError ¶
InvalidFieldError is returned when a field fails a call to Validate due to invalid input data.
The struct contains the name of the field which failed, human-readable details regarding its failure, and if possible, the error which caused the failure to be triggered.
func (*InvalidFieldError) Error ¶
func (e *InvalidFieldError) Error() string
Error returns a string representation of an InvalidFieldError.
type Notification ¶
type Notification struct { ID uint64 `db:"id" json:"id"` UserID uint64 `db:"user_id" json:"userId"` Timestamp uint64 `db:"timestamp" json:"timestamp"` Read bool `db:"read" json:"read"` Text string `db:"text" json:"text"` URI string `db:"uri" json:"uri"` }
Notification represents an application notification.
func (*Notification) SQLReadFields ¶
func (n *Notification) SQLReadFields() []interface{}
SQLReadFields returns the correct field order to scan SQL row results into the receiving Notification struct.
func (*Notification) SQLWriteFields ¶
func (n *Notification) SQLWriteFields() []interface{}
SQLWriteFields returns the correct field order for SQL write actions (such as insert or update), for the receiving Notification struct.
type Session ¶
type Session struct { ID uint64 `db:"id" json:"id"` UserID uint64 `db:"user_id" json:"userId"` Key string `db:"key" json:"key"` Expire uint64 `db:"expire" json:"expire"` }
Session represents an application session.
func NewSession ¶
NewSession creates a new session for the specified user ID, which will expire at the specified time.
func (*Session) IsExpired ¶
IsExpired returns if the current session is expired; meaning that the current UNIX timestamp is greater than the one set for the session.
func (*Session) SQLReadFields ¶
func (s *Session) SQLReadFields() []interface{}
SQLReadFields returns the correct field order to scan SQL row results into the receiving Session struct.
func (*Session) SQLWriteFields ¶
func (s *Session) SQLWriteFields() []interface{}
SQLWriteFields returns the correct field order for SQL write actions (such as insert or update), for the receiving Session struct.
type User ¶
type User struct { ID uint64 `db:"id" json:"id"` Username string `db:"username" json:"username"` FirstName string `db:"first_name" json:"firstName"` LastName string `db:"last_name" json:"lastName"` Email string `db:"email" json:"email"` Phone string `db:"phone" json:"phone"` Password string `db:"password" json:"password,omitempty"` }
User represents a user of the application.
func (*User) NewSession ¶
NewSession generates a new Session for this user.
func (*User) SQLReadFields ¶
func (u *User) SQLReadFields() []interface{}
SQLReadFields returns the correct field order to scan SQL row results into the receiving User struct.
func (*User) SQLWriteFields ¶
func (u *User) SQLWriteFields() []interface{}
SQLWriteFields returns the correct field order for SQL write actions (such as insert or update), for the receiving User struct.
func (*User) SetPassword ¶
SetPassword hashes the input password using bcrypt, storing the password within the receiving User struct.
func (*User) TryPassword ¶
TryPassword attempts to verify the input password against the receiving User's current password.