Documentation
¶
Overview ¶
Package users implements all business logic regarding users.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrAuthenticationFailure occurs when a user attempts to authenticate but // anything goes wrong. ErrAuthenticationFailure = errors.New("Authentication failed") )
Functions ¶
func Authenticate ¶
func Authenticate(ctx context.Context, db *sqlx.DB, now time.Time, email, password string) (auth.Claims, error)
Authenticate finds a user by their email and verifies their password. On success it returns a Claims value representing this user. The claims can be used to generate a token for future authentication.
Types ¶
type NewUser ¶
type NewUser struct {
Name string `json:"name" validate:"required"`
Email string `json:"email" validate:"required"`
Roles []string `json:"roles" validate:"required"`
Password string `json:"password" validate:"required"`
PasswordConfirm string `json:"password_confirm" validate:"eqfield=Password"`
}
NewUser contains information needed to create a new User.
type User ¶
type User struct {
ID string `db:"user_id" json:"id"`
Name string `db:"name" json:"name"`
Email string `db:"email" json:"email"`
Roles pq.StringArray `db:"roles" json:"roles"`
PasswordHash []byte `db:"password_hash" json:"-"`
DateCreated time.Time `db:"date_created" json:"dateCreated"`
DateUpdated time.Time `db:"date_updated" json:"dateUpdated"`
}
User represents someone with access to our system.
Click to show internal directories.
Click to hide internal directories.