models

package
v0.0.0-...-68e7828 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*gorm.DB
}

DB abstraction

func NewPostgresDB

func NewPostgresDB(dataSourceName string) *DB

NewPostgresDB - postgres database

func NewSqliteDB

func NewSqliteDB(databaseName string) *DB

NewSqliteDB - sqlite database

type Quote

type Quote struct {
	gorm.Model
	Text string
}

Quote struct

type QuoteManager

type QuoteManager struct {
	// contains filtered or unexported fields
}

QuoteManager struct

func NewQuoteManager

func NewQuoteManager(db *DB) (*QuoteManager, error)

NewQuoteManager - Create a quote manager that can be used for retrieving quotes

func (*QuoteManager) RandomQuote

func (qm *QuoteManager) RandomQuote() *Quote

RandomQuote - return a random quote

type User

type User struct {
	gorm.Model `json:"-"`
	Username   string `gorm:"not null;unique" json:"username"`
	Password   string `gorm:"not null" json:"-"`
	UUID       string `gorm:"not null;unique" json:"uuid"`
}

User struct

type UserManager

type UserManager struct {
	// contains filtered or unexported fields
}

UserManager struct

func NewUserManager

func NewUserManager(db *DB) (*UserManager, error)

NewUserManager - Create a new *UserManager that can be used for managing users.

func (*UserManager) AddUser

func (state *UserManager) AddUser(username, password string) *User

AddUser - Creates a user and hashes the password

func (*UserManager) CheckPassword

func (state *UserManager) CheckPassword(hashedPassword, password string) bool

CheckPassword - compare a hashed password with a possible plaintext equivalent

func (*UserManager) FindUser

func (state *UserManager) FindUser(username string) *User

FindUser -

func (*UserManager) FindUserByUUID

func (state *UserManager) FindUserByUUID(uuid string) *User

FindUserByUUID -

func (*UserManager) HasUser

func (state *UserManager) HasUser(username string) bool

HasUser - Check if the given username exists.

func (*UserManager) HashPassword

func (state *UserManager) HashPassword(username, password string) string

HashPassword - Hash the password (takes a username as well, it can be used for salting).

Jump to

Keyboard shortcuts

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