Documentation ¶
Overview ¶
Package usergrp maintains the group of handlers for user access.
Index ¶
- Variables
- type AppRegister
- type AppUpdateUser
- type AppUser
- type AppVerifyOTP
- type Handlers
- func (h *Handlers) Register(ctx context.Context, w http.ResponseWriter, r *http.Request) error
- func (h *Handlers) Token(ctx context.Context, w http.ResponseWriter, r *http.Request) error
- func (h *Handlers) Update(ctx context.Context, w http.ResponseWriter, r *http.Request) error
- func (h *Handlers) VerifyOTP(ctx context.Context, w http.ResponseWriter, r *http.Request) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidID = errors.New("id is not in its proper form") ErrInvalidStatus = errors.New("status is not allowed for this action") ErrInvalidOTP = errors.New("otp is invalid") )
Set of error variables for handling product group errors.
Functions ¶
This section is empty.
Types ¶
type AppRegister ¶
type AppRegister struct { FirstName string `json:"firstName" validate:"required"` LastName string `json:"lastName"` Phone string `json:"phone" validate:"required,number,startswith=0,len=10"` Password string `json:"password" validate:"required,min=6"` }
AppRegister contains information needed for a new user to register.
func (AppRegister) Validate ¶
func (r AppRegister) Validate() error
Validate checks the data in the model is considered clean.
type AppUpdateUser ¶
type AppUpdateUser struct { FirstName *string `json:"firstName"` LastName *string `json:"lastName"` Password *string `json:"password" validate:"omitempty,min=6"` }
func (AppUpdateUser) Validate ¶
func (r AppUpdateUser) Validate() error
Validate checks the data in the model is considered clean.
type AppUser ¶
type AppUser struct { ID string `json:"id"` FirstName string `json:"firstName"` LastName string `json:"lastName"` Phone string `json:"phone"` Roles []string `json:"roles"` PasswordHash []byte `json:"-"` Status string `json:"status"` CreatedAt string `json:"CreatedAt"` UpdatedAt string `json:"UpdatedAt"` }
AppUser represents information about an individual user.
type AppVerifyOTP ¶
type AppVerifyOTP struct { UserID string `json:"user_id" validate:"required,uuid"` OTP string `json:"otp" validate:"required,len=6"` }
func (AppVerifyOTP) Validate ¶
func (r AppVerifyOTP) Validate() error
Validate checks the data in the model is considered clean.
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
Handlers manages the set of user endpoints.
func (*Handlers) Register ¶
Register adds a new user to the system. TODO: limit the number of user can be created (use reCAPTCHA v3, limit by ip, device id)
Click to show internal directories.
Click to hide internal directories.