user

package
v0.0.0-...-ecc908a Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareHash

func CompareHash(hashedPassword, password string) error

func GenerateHash

func GenerateHash(password string) (string, error)

Types

type AuthInteractor

type AuthInteractor interface {
	CreateAccessToken(req entity.Authenticable) (string, error)
	CreateRefreshToken(req entity.Authenticable) (string, error)
	ParseToken(secret, requestToken string) (*authentication.Claims, error)
}

type Cache

type Cache interface {
	Exists(ctx context.Context, key string) (bool, error)
	Set(ctx context.Context, key string, value interface{}, expireTime time.Duration) error
	Get(ctx context.Context, key string) (string, error)
	Del(ctx context.Context, key string) (bool, error)
}

type Interactor

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

func New

func New(
	cfg *configs.Config,
	trc contract.Tracer,
	authIntr AuthInteractor,
	vld Validator,
	cache Cache,
	repository Repository,
) *Interactor

func (*Interactor) Login

func (*Interactor) Profile

func (*Interactor) RefreshToken

func (*Interactor) Register

type Repository

type Repository interface {
	Create(ctx context.Context, u entity.User) (entity.User, error)
	IsExistsByMobile(ctx context.Context, mobile string) (bool, error)
	GetByMobile(ctx context.Context, mobile string) (entity.User, error)
	GetByID(ctx context.Context, id uint64) (entity.User, error)
}

type Validator

type Validator interface {
	ValidateRegisterRequest(req user.RegisterRequest) (map[string]string, error)
	ValidateLoginRequest(req user.LoginRequest) (map[string]string, error)
	ValidateProfileRequest(req user.ProfileRequest) (map[string]string, error)
	ValidateRefreshTokenRequest(req user.RefreshTokenRequest) (map[string]string, error)
}

Directories

Path Synopsis
user_test

Jump to

Keyboard shortcuts

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