Documentation ¶
Overview ¶
Package repository implements methods of working with the repository objects
Index ¶
- Variables
- func RandomPassword(length int) string
- type Repository
- func (r *Repository) Count(ctx context.Context, filter *user.ListFilter) (int64, error)
- func (r *Repository) Create(ctx context.Context, userObj *model.User, password string) (uint64, error)
- func (r *Repository) CreateResetPassword(ctx context.Context, userID uint64) (*model.UserPasswordReset, error)
- func (r *Repository) Delete(ctx context.Context, id uint64) error
- func (r *Repository) EliminateResetPassword(ctx context.Context, userID uint64) error
- func (r *Repository) FetchList(ctx context.Context, filter *user.ListFilter, order *user.ListOrder, ...) ([]*model.User, error)
- func (r *Repository) Get(ctx context.Context, id uint64) (*model.User, error)
- func (r *Repository) GetByEmail(ctx context.Context, email string) (*model.User, error)
- func (r *Repository) GetByPassword(ctx context.Context, email, password string) (*model.User, error)
- func (r *Repository) GetByToken(ctx context.Context, token string) (*model.User, *model.Account, error)
- func (r *Repository) GetResetPassword(ctx context.Context, userID uint64, token string) (*model.UserPasswordReset, error)
- func (r *Repository) SetPassword(ctx context.Context, userObj *model.User, password string) error
- func (r *Repository) Update(ctx context.Context, userObj *model.User) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidPassword = errors.New(`invalid password`) ErrInvalidUserObject = errors.New(`invalid object`) )
Errors list...
Functions ¶
func RandomPassword ¶
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 (*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) GetByEmail ¶
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 ¶
SetPassword to the user