Documentation ¶
Index ¶
- func ActionAuthenticateUser(w http.ResponseWriter, r *http.Request)
- func ActionGetAuthenticatedUser(w http.ResponseWriter, r *http.Request)
- func ActionRegisterUser(w http.ResponseWriter, r *http.Request)
- type Config
- type SimpleUser
- type Token
- type User
- func (u *User) CreateUser(email, password string) error
- func (u *User) FetchUserTokenByID(id int64) (*Token, error)
- func (u *User) FindUserByEmail(email string) (*User, error)
- func (u *User) FindUserByEmailAndPassword(email, password string) (*User, error)
- func (u *User) FindUserByID(id int64) (*User, error)
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.
type SimpleUser ¶
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 (*User) CreateUser ¶
CreateUser creates a new User record with an email and password, and saves it to the database.
func (*User) FetchUserTokenByID ¶
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 ¶
FindUserByEmail queries the database for a User record by its email/username.
func (*User) FindUserByEmailAndPassword ¶
FindUserByEmailAndPassword queries the database for a User record by its username/password pair.