user

package
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2024 License: LGPL-2.1 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIncorrectPassword = server.NewHTTPError(http.StatusBadRequest, "INCORRECT_PASSWORD", "Incorrect old password")
	ErrUserNotFound      = server.NewHTTPError(http.StatusBadRequest, "USER_NOTFOUND", "User not found")
	ErrEmailExisted      = server.NewHTTPValidationError("Email already existed")
)

Custom errors

Functions

func NewHTTP

func NewHTTP(svc Service, eg *echo.Group)

NewHTTP attaches handlers to Echo routers under given group

Types

type ChangePasswordReq

type ChangePasswordReq struct {
	OldPassword        string `json:"old_password" validate:"required"`
	NewPassword        string `json:"new_password" validate:"required,min=8"`
	NewPasswordConfirm string `json:"new_password_confirm" validate:"required,eqfield=NewPassword"`
}

ChangePasswordReq contains request data to change user password swagger:model

type CreateUserReq

type CreateUserReq struct {
	FirstName string `json:"first_name" validate:"required"`
	LastName  string `json:"last_name" validate:"required"`
	Email     string `json:"email" validate:"required,email"`
	Phone     string `json:"phone" validate:"required,phone"`
	Password  string `json:"password" validate:"required,min=8"`
	Role      string `json:"role" validate:"required"`
	Status    string `json:"status"`
}

CreateUserReq contains request data to create new user swagger:model

type Crypter

type Crypter interface {
	CompareHashAndPassword(string, string) bool
	HashPassword(string) string
}

Crypter represents security interface

type HTTP

type HTTP struct {
	contextutil.Context
	// contains filtered or unexported fields
}

HTTP represents user http service

type ListUserReq

type ListUserReq struct {
	requestutil.ListQueryRequest
	Name string `json:"name,omitempty" query:"name"`
	// Search for user(s) by name, email, or phone
	Search string `json:"search,omitempty" query:"search"`
}

ListUserReq contains request data to get list of users swagger:parameters usersList

func (*ListUserReq) ToListCond

ToListCond transforms the service request to repo conditions

type ListUsersResp

type ListUsersResp struct {
	Data       []*types.User `json:"data"`
	TotalCount int64         `json:"total_count"`
}

ListUsersResp contains list of paginated users and total numbers after filtered swagger:model

type Service

Service represents user application interface

type UpdateUserReq

type UpdateUserReq struct {
	FirstName *string `json:"first_name,omitempty"`
	LastName  *string `json:"last_name,omitempty"`
	Email     *string `json:"email,omitempty" validate:"omitempty,email"`
	Phone     *string `json:"phone,omitempty" validate:"omitempty,phone"`
	Role      *string `json:"role,omitempty"`
	Status    *string `json:"status,omitempty"`
}

UpdateUserReq contains request data to update existing user swagger:model

type User

type User struct {
	// contains filtered or unexported fields
}

User represents user application service

func New

func New(repo *repo.Service, rbacSvc rbac.Intf, cr Crypter) *User

New creates new user application service

func (*User) ChangePassword

func (s *User) ChangePassword(c contextutil.Context, data ChangePasswordReq) error

ChangePassword changes user password

func (*User) Create

func (s *User) Create(c contextutil.Context, data CreateUserReq) (*types.User, error)

Create creates new user

func (*User) Delete

func (s *User) Delete(c contextutil.Context, id string) error

Delete deletes user by id

func (*User) List

func (s *User) List(c contextutil.Context, req ListUserReq) (*ListUsersResp, error)

List returns the list of users

func (*User) Me

func (s *User) Me(c contextutil.Context) (*types.User, error)

Me returns current authenticated user

func (*User) Read

func (s *User) Read(c contextutil.Context, id string) (*types.User, error)

Read returns single user by id

func (*User) Update

func (s *User) Update(c contextutil.Context, id string, data UpdateUserReq) (*types.User, error)

Update updates user information

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL