user

package
v0.0.0-...-245b194 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionAuthenticateUser

func ActionAuthenticateUser(w http.ResponseWriter, r *http.Request)

func ActionGetAuthenticatedUser

func ActionGetAuthenticatedUser(w http.ResponseWriter, r *http.Request)

func ActionRegisterUser

func ActionRegisterUser(w http.ResponseWriter, r *http.Request)

Types

type Config

type Config struct {
	DBDriver   string `json:"db_driver"`
	DBUser     string `json:"db_user"`
	DBPassword string `json:"db_password"`
	DBAddress  string `json:"db_address"`
	DBTable    string `json:"db_table"`

	EncodingJWT string `json:"encoding_jwt"`
	// contains filtered or unexported fields
}

Config represents individual configuration definitions derrived from the `config.json` file.

func (*Config) LoadJSON

func (c *Config) LoadJSON() error

type SimpleUser

type SimpleUser struct {
	ID    int64  `json:"id"`
	Email string `json:"email"`
}

A SimpleUser represents a simpler version of User without any of the supperfluous database fields. Used for API responses.

type Token

type Token struct {
	Token string `json:"token"`
}

A Token is a <a href="http://jwt.io">JSON Web Token</a> representation of a User authenticated session.

type User

type User struct {
	ID       int64  `db:"id"`
	Email    string `db:"email"`
	Password string `db:"password"`
	// contains filtered or unexported fields
}

A User represents the database record of the user model.

func LoadUser

func LoadUser() (*User, error)

func (*User) CreateUser

func (u *User) CreateUser(email, password string) error

CreateUser creates a new User record with an email and password, and saves it to the database.

func (*User) FetchUserTokenByID

func (u *User) FetchUserTokenByID(id int64) (*Token, error)

FetchUserTokenByID retrieves a user by it's primary key, and then encodes it into a <a href="http://jwt.io">JSON Web Token</a>.

func (*User) FindUserByEmail

func (u *User) FindUserByEmail(email string) (*User, error)

FindUserByEmail queries the database for a User record by its email/username.

func (*User) FindUserByEmailAndPassword

func (u *User) FindUserByEmailAndPassword(email, password string) (*User, error)

FindUserByEmailAndPassword queries the database for a User record by its username/password pair.

func (*User) FindUserByID

func (u *User) FindUserByID(id int64) (*User, error)

FindUserByID retrieves a User record from the database by its index.

Jump to

Keyboard shortcuts

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