user

package
v0.0.0-...-2a11bd6 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package user contains the service for user interactions

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInsecurePassword = echo.NewHTTPError(http.StatusBadRequest, "insecure password")
)

Custom errors

Functions

This section is empty.

Types

type DBClientInterface

type DBClientInterface interface {
	Create(*gorm.DB, models.User) (*models.User, error)
	View(*gorm.DB, uint) (*models.User, error)
	List(*gorm.DB, *models.ListQuery, *models.Pagination) ([]models.User, error)
	Update(*gorm.DB, *models.User) error
	Delete(*gorm.DB, *models.User) error
}

DBClientInterface represents user repository interface

type RBAC

type RBAC interface {
	User(echo.Context) *models.AuthUser
	EnforceUser(echo.Context, uint) error
	AccountCreate(echo.Context, models.AccessRole, uint, uint) error
	IsLowerRole(echo.Context, models.AccessRole) error
}

RBAC represents role-based-access-control interface

type RequestHandler

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

RequestHandler represents user application service

func Initialize

func Initialize(db *gorm.DB, rbac RBAC, sec Securer) *RequestHandler

Initialize initalizes User RequestHandler application service with defaults

func New

func New(db *gorm.DB, udb DBClientInterface, rbac RBAC, sec Securer) *RequestHandler

New creates new user RequestHandler application service

func (*RequestHandler) Create

func (u *RequestHandler) Create(c echo.Context, req models.User) (*models.User, error)

Create creates a new user account

func (*RequestHandler) Delete

func (u *RequestHandler) Delete(c echo.Context, id uint) error

Delete deletes a user

func (*RequestHandler) List

List returns list of users

func (*RequestHandler) Update

func (u *RequestHandler) Update(c echo.Context, req *Update) (*models.User, error)

Update updates user's contact information

func (*RequestHandler) View

func (u *RequestHandler) View(c echo.Context, id uint) (*models.User, error)

View returns single user

type Securer

type Securer interface {
	Hash(string) string
	Password(string, ...string) bool
}

Securer represents security interface

type Service

type Service interface {
	Create(echo.Context, models.User) (*models.User, error)
	View(echo.Context, uint) (*models.User, error)
	List(echo.Context, *models.Pagination) ([]models.User, error)
	Update(echo.Context, *Update) (*models.User, error)
	Delete(echo.Context, uint) error
}

Service represents user application interface

type Update

type Update struct {
	ID        uint
	FirstName *string
	LastName  *string
	Mobile    *string
	Phone     *string
	Address   *string
}

Update contains user's information used for updating

Directories

Path Synopsis
Package transport contains the HTTP service for user interactions
Package transport contains the HTTP service for user interactions

Jump to

Keyboard shortcuts

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