model

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2018 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DestroyApiKey added in v0.0.6

func DestroyApiKey(db *sqlx.DB, user, clientID string) error

func DestroyApiKeys added in v0.0.6

func DestroyApiKeys(db *sqlx.DB, uid string) error

func DestroyToken

func DestroyToken(db *sqlx.DB, token string) error

func DestroyTokenByUser added in v0.0.5

func DestroyTokenByUser(db *sqlx.DB, uid string) error

func IncrementToken

func IncrementToken(db *sqlx.DB, token string) error

func NewDB added in v0.0.5

func NewDB(driver, dsn string) (*sqlx.DB, error)

func RandKey added in v0.0.6

func RandKey() (string, error)

func RefreshApiKey added in v0.0.6

func RefreshApiKey(db *sqlx.DB, ak *ApiKey) error

func RemoveAnswer added in v0.0.5

func RemoveAnswer(db *sqlx.DB, uid string) error

func SignToken added in v0.0.4

func SignToken(salt, token string) string

func StoreAnswer

func StoreAnswer(db *sqlx.DB, user, ans string, qid int) error

func VerifyToken added in v0.0.4

func VerifyToken(salt, signedToken string) (string, bool)

Types

type ApiKey added in v0.0.6

type ApiKey struct {
	UserName     string     `db:"user_name"`
	Key          string     `db:"api_key"`
	ClientID     string     `db:"client_id"`
	Scopes       string     `db:"scopes"`
	CreatedAt    *time.Time `db:"created_at"`
	LastAccessed *time.Time `db:"last_accessed"`
}

func CreateApiKey added in v0.0.6

func CreateApiKey(db *sqlx.DB, uid, clientID, scopes string) (*ApiKey, string, error)

func FetchApiKey added in v0.0.6

func FetchApiKey(db *sqlx.DB, key string) (*ApiKey, error)

func FetchApiKeys added in v0.0.6

func FetchApiKeys(db *sqlx.DB, uid string) ([]*ApiKey, error)

type SecurityAnswer

type SecurityAnswer struct {
	UserName   string     `db:"user_name"`
	QuestionID int        `db:"question_id"`
	Question   string     `db:"question"`
	Answer     string     `db:"answer"`
	CreatedAt  *time.Time `db:"created_at"`
}

func FetchAnswer

func FetchAnswer(db *sqlx.DB, uid string) (*SecurityAnswer, error)

func (*SecurityAnswer) Verify added in v0.0.5

func (a *SecurityAnswer) Verify(ans string) bool

Verify security answer

type SecurityQuestion

type SecurityQuestion struct {
	ID       int    `db:"id"`
	Question string `db:"question"`
}

func FetchQuestions

func FetchQuestions(db *sqlx.DB) ([]*SecurityQuestion, error)

type Token

type Token struct {
	UserName  string     `db:"user_name"`
	Email     string     `db:"email"`
	Token     string     `db:"token"`
	Attempts  int        `db:"attempts"`
	CreatedAt *time.Time `db:"created_at"`
}

func CreateToken added in v0.0.5

func CreateToken(db *sqlx.DB, uid, email string) (*Token, error)

func FetchToken

func FetchToken(db *sqlx.DB, token string, maxAge int) (*Token, error)

func FetchTokenByUser

func FetchTokenByUser(db *sqlx.DB, uid string, maxAge int) (*Token, error)

Jump to

Keyboard shortcuts

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