user

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package user present full API functionality of the specific object

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePasswords

func ComparePasswords(hashedPwd string, plainPwd []byte) error

ComparePasswords between income password and generated hash

func PasswordHash

func PasswordHash(pwd []byte) (string, error)

PasswordHash process and return processed password to bcrypt hash

func SetSalt

func SetSalt(s []byte, c int)

SetSalt for passowrd

Types

type ListFilter

type ListFilter struct {
	AccountID []uint64
	UserID    []uint64
	Emails    []string
	Roles     []uint64
}

ListFilter object with filtered values which is not NULL

func (*ListFilter) PrepareQuery

func (fl *ListFilter) PrepareQuery(q *gorm.DB) *gorm.DB

PrepareQuery returns the query with applied filters

type ListOrder

type ListOrder struct {
	ID        model.Order
	Email     model.Order
	Status    model.Order
	CreatedAt model.Order
	UpdatedAt model.Order
}

ListOrder object with order values which is not NULL

func (*ListOrder) PrepareQuery

func (ord *ListOrder) PrepareQuery(q *gorm.DB) *gorm.DB

PrepareQuery returns the query with applied order

type Repository

type Repository interface {
	Get(ctx context.Context, id uint64) (*model.User, error)
	GetByEmail(ctx context.Context, email string) (*model.User, error)
	GetByPassword(ctx context.Context, email, password string) (*model.User, error)
	GetByToken(ctx context.Context, token string) (*model.User, *model.Account, error)
	FetchList(ctx context.Context, filter *ListFilter, order *ListOrder, page *repository.Pagination) ([]*model.User, error)
	Count(ctx context.Context, filter *ListFilter) (int64, error)
	Create(ctx context.Context, user *model.User, password string) (uint64, error)
	Update(ctx context.Context, user *model.User) error
	Delete(ctx context.Context, id uint64) error

	SetPassword(ctx context.Context, user *model.User, password string) error
	CreateResetPassword(ctx context.Context, userID uint64) (*model.UserPasswordReset, error)
	GetResetPassword(ctx context.Context, userID uint64, token string) (*model.UserPasswordReset, error)
	EliminateResetPassword(ctx context.Context, userID uint64) error
}

Repository describes basic user methods

type Usecase

type Usecase interface {
	Get(ctx context.Context, id uint64) (*model.User, error)
	GetByEmail(ctx context.Context, email string) (*model.User, error)
	GetByPassword(ctx context.Context, email, password string) (*model.User, error)
	GetByToken(ctx context.Context, token string) (*model.User, *model.Account, error)
	FetchList(ctx context.Context, filter *ListFilter, order *ListOrder, page *repository.Pagination) ([]*model.User, error)
	Count(ctx context.Context, filter *ListFilter) (int64, error)
	Store(ctx context.Context, user *model.User, password string) (uint64, error)
	Update(ctx context.Context, user *model.User) error
	Delete(ctx context.Context, id uint64) error

	SetPassword(ctx context.Context, user *model.User, password string) error
	ResetPassword(ctx context.Context, email string) (*model.UserPasswordReset, *model.User, error)
	UpdatePassword(ctx context.Context, token, email, password string) error
}

Usecase describes basic user methods

Directories

Path Synopsis
delivery
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package repository implements methods of working with the repository objects
Package repository implements methods of working with the repository objects
Package usecase user managing
Package usecase user managing

Jump to

Keyboard shortcuts

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