models

package
v0.0.0-...-75fea4d Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateUser

func CreateUser(username string, email string, password string, db *sqlx.DB) error

CreateUser creates a new, validated user

func OpenDB

func OpenDB() *sqlx.DB

OpenDB gets a new handle to the database or returns the existing one

Types

type Episode

type Episode struct {
	ID          int64     `json:"-"`
	Title       string    `json:"title"`
	ReleaseDate time.Time `json:"date"`
	Season      int64     `json:"season"`
	Number      int64     `json:"id"`
	Files       []string  `json:"-"`
	SeriesID    int64     `json:"-"`
}

func (*Episode) Save

func (e *Episode) Save(db *sqlx.DB) error

type Series

type Series struct {
	ID          int64  `json:"id"`
	Title       string `json:"title"`
	Description string `json:"description"`
	PosterURL   string `json:"poster"`
	Seasons     int    `json:"seasons"`
}

func GetAllSeries

func GetAllSeries(db *sqlx.DB) []Series

func GetSeriesByID

func GetSeriesByID(id int64, db *sqlx.DB) (*Series, error)

func GetSeriesByTitle

func GetSeriesByTitle(title string, db *sqlx.DB) (*Series, error)

func (*Series) GetEpisodes

func (s *Series) GetEpisodes(db *sqlx.DB) ([]Episode, error)

func (*Series) Save

func (s *Series) Save(db *sqlx.DB) error

type User

type User struct {
	ID int64

	Username     string
	Email        string
	PasswordHash string

	Admin         bool `json:"-"`
	PasswordReset bool `json:"-"`
	Confirmed     bool `json:"-"`
}

User model

func CheckToken

func CheckToken(token string) (*User, error)

CheckToken checks an authentication token user/expiry/etc against db

func FindUser

func FindUser(username string, db *sqlx.DB) (*User, error)

FindUser a user by username

func (*User) CheckPassword

func (u *User) CheckPassword(password string) (bool, error)

CheckPassword checks a users password against the password hash and returns a bool and any errors

func (*User) Confirm

func (u *User) Confirm(cc string) error

Confirm the user based on the confirmation code passed

func (*User) ConfirmPasswordReset

func (u *User) ConfirmPasswordReset(prCode string) error

ConfirmPasswordReset sends a password reset email and sets passwordReset to true

func (*User) GenAuthToken

func (u *User) GenAuthToken() (*string, error)

GenAuthToken generates a signed authentication token for the user

func (*User) GenConfirmationCode

func (u *User) GenConfirmationCode() (*string, error)

GenConfirmationCode creates a confirmationcode using crypto

func (*User) Save

func (u *User) Save(validate bool) error

Save a user to the database, optionally validating - ensures no duplicates and updates any existing record with the same ID nothing persists to the database but (*User).Save()

func (*User) StartPasswordReset

func (u *User) StartPasswordReset() error

StartPasswordReset sends a password reset email and sets passwordReset to true

Jump to

Keyboard shortcuts

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