Documentation ¶
Overview ¶
Package user contains user related CRUD functionality.
Index ¶
- type Info
- type NewUser
- type Store
- func (s Store) Authenticate(ctx context.Context, traceID string, now time.Time, email, password string) (auth.Claims, error)
- func (s Store) Create(ctx context.Context, traceID string, nu NewUser, now time.Time) (Info, error)
- func (s Store) Delete(ctx context.Context, traceID string, claims auth.Claims, userID string) error
- func (s Store) Query(ctx context.Context, traceID string, pageNumber int, rowsPerPage int) ([]Info, error)
- func (s Store) QueryByEmail(ctx context.Context, traceID string, claims auth.Claims, email string) (Info, error)
- func (s Store) QueryByID(ctx context.Context, traceID string, claims auth.Claims, userID string) (Info, error)
- func (s Store) Update(ctx context.Context, traceID string, claims auth.Claims, userID string, ...) error
- type UpdateUser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct { ID string `db:"user_id" json:"id"` Name string `db:"name" json:"name"` Email string `db:"email" json:"email"` Roles []string `db:"roles" json:"roles"` PasswordHash string `db:"password_hash" json:"-"` DateCreated time.Time `db:"date_created" json:"date_created"` DateUpdated time.Time `db:"date_updated" json:"date_updated"` }
Info represents an individual user.
type NewUser ¶
type NewUser struct { Name string `json:"name" validate:"required"` Email string `json:"email" validate:"required,email"` 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 Store ¶ added in v0.3.3
type Store struct {
// contains filtered or unexported fields
}
Store manages the set of API's for user access.
func (Store) Authenticate ¶ added in v0.3.3
func (s Store) Authenticate(ctx context.Context, traceID string, now time.Time, email, password string) (auth.Claims, error)
Authenticate finds a user by their email and verifies their password. On success it returns claims representing this user. The claims can be used to generate a token for future authentication.
func (Store) Query ¶ added in v0.3.3
func (s Store) Query(ctx context.Context, traceID string, pageNumber int, rowsPerPage int) ([]Info, error)
Query retrieves a list of existing users from the database.
func (Store) QueryByEmail ¶ added in v0.3.3
func (s Store) QueryByEmail(ctx context.Context, traceID string, claims auth.Claims, email string) (Info, error)
QueryByEmail gets the specified user from the database by email.
type UpdateUser ¶
type UpdateUser struct { Name *string `json:"name"` Email *string `json:"email" validate:"omitempty,email"` Roles []string `json:"roles"` Password *string `json:"password"` PasswordConfirm *string `json:"password_confirm" validate:"omitempty,eqfield=Password"` }
UpdateUser defines what information may be provided to modify an existing User. All fields are optional so clients can send just the fields they want changed. It uses pointer fields so we can differentiate between a field that was not provided and a field that was provided as explicitly blank. Normally we do not want to use pointers to basic types but we make exceptions around marshalling/unmarshalling.