usecase

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package usecase user managing

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPasswordResetCode = errors.New(`invalid password reset code`)
	ErrInvalidCurrentPassword   = errors.New(`current password is incorrect`)
	ErrPasswordTooShort         = errors.New(`password must be at least 8 characters`)
)

Functions

func NewEmailUsecase added in v0.5.0

func NewEmailUsecase[T user.EmailCapableModel](emailRepo user.EmailRepository[T], _ func() T) user.EmailUsecase[T]

NewEmailUsecase creates email usecase.

func NewPasswordUsecase added in v0.5.0

func NewPasswordUsecase[T user.PasswordCapableModel](core user.Usecase[T], passRepo user.PasswordRepository[T]) user.PasswordUsecase[T]

NewPasswordUsecase creates password usecase.

func NewUsecase added in v0.5.0

func NewUsecase[T user.Model](repo user.Repository[T]) user.Usecase[T]

NewUsecase creates generic core user usecase.

Types

type EmailUsecase added in v0.5.0

type EmailUsecase[T user.EmailCapableModel] struct {
	// contains filtered or unexported fields
}

EmailUsecase provides email lookup business logic.

func (*EmailUsecase[T]) GetByEmail added in v0.5.0

func (a *EmailUsecase[T]) GetByEmail(ctx context.Context, email string) (T, error)

GetByEmail retrieves user by email (case-insensitive) with access control check.

type PasswordUsecase added in v0.5.0

type PasswordUsecase[T user.PasswordCapableModel] struct {
	// contains filtered or unexported fields
}

PasswordUsecase provides password business logic.

func (*PasswordUsecase[T]) ChangePassword added in v0.5.0

func (a *PasswordUsecase[T]) ChangePassword(ctx context.Context, currentPassword, newPassword string) error

ChangePassword changes the password for the current user with access control check.

func (*PasswordUsecase[T]) Repo added in v0.5.0

func (a *PasswordUsecase[T]) Repo() user.PasswordRepository[T]

Repo returns the underlying password repository.

func (*PasswordUsecase[T]) ResetPassword added in v0.5.0

func (a *PasswordUsecase[T]) ResetPassword(ctx context.Context, userID uint64) (*user.UserPasswordReset, T, error)

ResetPassword generates a password reset token for the user with access control check.

func (*PasswordUsecase[T]) SetPassword added in v0.5.0

func (a *PasswordUsecase[T]) SetPassword(ctx context.Context, userObj T, password string) error

SetPassword sets a new password for the user with access control check.

func (*PasswordUsecase[T]) UpdatePassword added in v0.5.0

func (a *PasswordUsecase[T]) UpdatePassword(ctx context.Context, userID uint64, token, password string) error

UpdatePassword updates the password for the user using a reset token with access control check.

type UserUsecase

type UserUsecase[T user.Model] struct {
	// contains filtered or unexported fields
}

UserUsecase provides business logic for user access.

func (*UserUsecase[T]) Count

func (a *UserUsecase[T]) Count(ctx context.Context, opts ...user.QOption) (int64, error)

func (*UserUsecase[T]) Create added in v0.4.0

func (a *UserUsecase[T]) Create(ctx context.Context, userObj T) (uint64, error)

func (*UserUsecase[T]) Delete

func (a *UserUsecase[T]) Delete(ctx context.Context, id uint64) error

func (*UserUsecase[T]) EmptyObject added in v0.5.0

func (a *UserUsecase[T]) EmptyObject() T

func (*UserUsecase[T]) FetchList

func (a *UserUsecase[T]) FetchList(ctx context.Context, opts ...user.QOption) ([]T, error)

func (*UserUsecase[T]) Get

func (a *UserUsecase[T]) Get(ctx context.Context, id uint64) (T, error)

func (*UserUsecase[T]) Update

func (a *UserUsecase[T]) Update(ctx context.Context, userObj T) error

Jump to

Keyboard shortcuts

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