repository

package
v0.0.0-...-833fa1d Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package repository implements methods of working with the repository objects

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPassword   = errors.New(`invalid password`)
	ErrInvalidUserObject = errors.New(`invalid object`)
)

Errors list...

Functions

func RandomPassword

func RandomPassword(length int) string

RandomPassword returns a random password of the given length

Types

type Repository

type Repository struct {
	repository.Repository
}

Repository DAO which provides functionality of working with users and authorization

func New

func New() *Repository

New repository accessor to work with users and profiles

func (*Repository) Count

func (r *Repository) Count(ctx context.Context, filter *user.ListFilter) (int64, error)

Count of users by filter

func (*Repository) Create

func (r *Repository) Create(ctx context.Context, userObj *model.User, password string) (uint64, error)

Create new user object to database

func (*Repository) CreateResetPassword

func (r *Repository) CreateResetPassword(ctx context.Context, userID uint64) (*model.UserPasswordReset, error)

CreateResetPassword creates new reset password token

func (*Repository) Delete

func (r *Repository) Delete(ctx context.Context, id uint64) error

Delete delites record by ID

func (*Repository) EliminateResetPassword

func (r *Repository) EliminateResetPassword(ctx context.Context, userID uint64) error

EliminateResetPassword removes reset password token

func (*Repository) FetchList

func (r *Repository) FetchList(ctx context.Context, filter *user.ListFilter, order *user.ListOrder, page *repository.Pagination) ([]*model.User, error)

FetchList of users by filter

func (*Repository) Get

func (r *Repository) Get(ctx context.Context, id uint64) (*model.User, error)

Get one object by ID

func (*Repository) GetByEmail

func (r *Repository) GetByEmail(ctx context.Context, email string) (*model.User, error)

GetByEmail one object by Email

func (*Repository) GetByPassword

func (r *Repository) GetByPassword(ctx context.Context, email, password string) (*model.User, error)

GetByPassword user returns user object by password

func (*Repository) GetByToken

func (r *Repository) GetByToken(ctx context.Context, token string) (*model.User, *model.Account, error)

GetByToken returns the user object linked to the token (external session ID)

func (*Repository) GetResetPassword

func (r *Repository) GetResetPassword(ctx context.Context, userID uint64, token string) (*model.UserPasswordReset, error)

GetResetPassword returns reset password token

func (*Repository) SetPassword

func (r *Repository) SetPassword(ctx context.Context, userObj *model.User, password string) error

SetPassword to the user

func (*Repository) Update

func (r *Repository) Update(ctx context.Context, userObj *model.User) error

Update existing object in database

Jump to

Keyboard shortcuts

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