source

package
v0.0.0-...-efccb87 Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectToDB

func ConnectToDB(config configStruct.Configuration) (*sql.DB, error)

ConnectToDB attempts to connect to the database and returns a pointer to the database along with an error if applicable

func CreateJWT

func CreateJWT(userID string) (string, error)

CreateJWT return a JWT token for the given user ID input

func DecodeJWT

func DecodeJWT(JWT string) (string, error)

DecodeJWT decode the specified token and return the associated user ID

func GetConfig

func GetConfig(prefix string) config.Configuration

GetConfig builds and returns a Configuration struct Loads from a .yml file

func GetUser

func GetUser(dialect goqu.DialectWrapper, db *sql.DB, userID string, userEmail string) (models.User, error)

GetUser - Lookup the user based on ID, returns the model or alternatively an empty user along with an error

func GetUserFromToken

func GetUserFromToken(currentContext context.Context, dialect goqu.DialectWrapper, db *sql.DB) (models.User, error)

GetUserFromToken - Lookup the user based on context (Authorization token) returns the user model or alternatively an error

func Hash

func Hash(text string) (string, error)

Hash - Hash the text using bcrypt, return the hash or an error

func InitTables

func InitTables(dialect goqu.DialectWrapper, db *sql.DB) error

InitTables - Create and load DB tables with data returns an error or nil if no error ocurred

func ValidHash

func ValidHash(text string, hashedText string) (bool, error)

ValidHash - Compare the hash and text using bcrypt, returns true if valid or false along with an error if invalid

Types

type Claims

type Claims struct {
	UserID string `json:"userID"`
	jwt.StandardClaims
}

Claims associated with the JWT data stored

Jump to

Keyboard shortcuts

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