Documentation ¶
Index ¶
- Variables
- func Create(ctx context.Context, db sqlx.ExtContext, user User) error
- func HandleCreate(db *sqlx.DB) web.Handler
- func HandleShow(db *sqlx.DB) web.Handler
- func HandleShowCurrent(db *sqlx.DB) web.Handler
- type User
- func Fetch(ctx context.Context, db sqlx.ExtContext, id string) (User, error)
- func FetchByEmail(ctx context.Context, db sqlx.ExtContext, email string) (User, error)
- func FetchByToken(ctx context.Context, db sqlx.ExtContext, tokenHash []byte, tokenScope string) (User, error)
- func Update(ctx context.Context, db sqlx.ExtContext, user User) (User, error)
- type UserNew
- type UserSignup
- type UserUp
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrUniqueEmail = errors.New("email is not unique")
)
Functions ¶
func HandleCreate ¶
HandleCreate allows administrators to create new users.
func HandleShow ¶
HandleShow returns the information of a user.
Types ¶
type User ¶
type User struct { ID string `json:"id" db:"user_id"` Name string `json:"name" db:"name"` Email string `json:"email" db:"email"` Role string `json:"role" db:"role"` Active bool `json:"active" db:"active"` PasswordHash []byte `json:"-" db:"password_hash"` CreatedAt time.Time `json:"createdAt" db:"created_at"` UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` Version int `json:"-" db:"version"` }
User models users. Email address is a unique field.
func FetchByEmail ¶
FetchByEmail returns the user corresponding to a specific email, if any.
func FetchByToken ¶
func FetchByToken(ctx context.Context, db sqlx.ExtContext, tokenHash []byte, tokenScope string) (User, error)
FetchByToken retrieves the user corresponding to the passed token.
type UserNew ¶
type UserNew struct { Name string `json:"name" validate:"required"` Email string `json:"email" validate:"required,email"` Role string `json:"role" validate:"required"` Password string `json:"password" validate:"required"` PasswordConfirm string `json:"passwordConfirm" validate:"eqfield=Password"` }
UserNew includes the information an administrator needs to create a new user.
type UserSignup ¶
type UserSignup struct { Name string `json:"name" validate:"required"` Email string `json:"email" validate:"required,email"` Password string `json:"password" validate:"required,gte=8,lte=50"` PasswordConfirm string `json:"passwordConfirm" validate:"omitempty,eqfield=Password"` }
UserSignup contains information needed to register a user.
type UserUp ¶
type UserUp struct { Name *string `json:"name"` Email *string `json:"email" validate:"omitempty,email"` Role *string `json:"role"` Password *string `json:"password"` PasswordConfirm *string `json:"passwordConfirm" validate:"omitempty,eqfield=Password"` }
UserUp specifies information of a user which can be updated.
Click to show internal directories.
Click to hide internal directories.