common

package
v1.14.21 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IntervalTime = 60
)

Variables

View Source
var (
	ErrVerificationCodeInvalid      = errors.New("verification code is invalid or expired")
	ErrVerificationAttemptsExceeded = errors.New("verification code attempt limit exceeded")
)

Functions

func DeleteVerificationCode added in v1.14.1

func DeleteVerificationCode(ctx context.Context, client *redis.Client, cacheKey string) error

func SaveVerificationCode added in v1.14.1

func SaveVerificationCode(ctx context.Context, client *redis.Client, cacheKey, code string, expiration time.Duration) error

func ValidateVerificationCode added in v1.14.1

func ValidateVerificationCode(ctx context.Context, client *redis.Client, cacheKey, supplied string, consume bool) error

ValidateVerificationCode rate-limits guesses and optionally consumes a correct code atomically. A registration or account mutation must consume it; a UI pre-check may validate without consuming it.

Types

type CheckVerificationCodeLogic

type CheckVerificationCodeLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewCheckVerificationCodeLogic

func NewCheckVerificationCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckVerificationCodeLogic

Check verification code

func (*CheckVerificationCodeLogic) CheckVerificationCode

type EmailCodeConfig added in v1.14.19

type EmailCodeConfig struct {
	DomainSuffixList   string
	EnableDomainSuffix bool
	VerifyCodeInterval int64
	VerifyCodeLimit    int64
	VerifyCodeExpire   int64
	SiteName           string
}

EmailCodeConfig is the configuration snapshot consumed by email code delivery.

type GetAdsLogic

type GetAdsLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewGetAdsLogic

func NewGetAdsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAdsLogic

Get Ads

func (*GetAdsLogic) GetAds

func (l *GetAdsLogic) GetAds(req *dto.GetAdsRequest) (resp *dto.GetAdsResponse, err error)

type GetClientLogic added in v1.0.4

type GetClientLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewGetClientLogic added in v1.0.4

func NewGetClientLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClientLogic

Get Client

func (*GetClientLogic) GetClient added in v1.0.4

func (l *GetClientLogic) GetClient() (resp *dto.GetSubscribeClientResponse, err error)

type GetGlobalConfigDependencies added in v1.14.19

type GetGlobalConfigDependencies struct {
	Store  GlobalConfigStore
	Config GlobalConfigSnapshot
}

GetGlobalConfigDependencies explicitly declares the collaborators of the global configuration query instead of passing ServiceContext to business logic.

type GetGlobalConfigLogic

type GetGlobalConfigLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewGetGlobalConfigLogic

func NewGetGlobalConfigLogic(ctx context.Context, deps GetGlobalConfigDependencies) *GetGlobalConfigLogic

Get global config

func (*GetGlobalConfigLogic) GetGlobalConfig

func (l *GetGlobalConfigLogic) GetGlobalConfig() (resp *dto.GetGlobalConfigResponse, err error)

type GetPrivacyPolicyLogic

type GetPrivacyPolicyLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewGetPrivacyPolicyLogic

func NewGetPrivacyPolicyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPrivacyPolicyLogic

Get Privacy Policy

func (*GetPrivacyPolicyLogic) GetPrivacyPolicy

func (l *GetPrivacyPolicyLogic) GetPrivacyPolicy() (resp *dto.PrivacyPolicyConfig, err error)

type GetStatLogic

type GetStatLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewGetStatLogic

func NewGetStatLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetStatLogic

Get Tos

func (*GetStatLogic) GetStat

func (l *GetStatLogic) GetStat() (resp *dto.GetStatResponse, err error)

type GetTosLogic

type GetTosLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewGetTosLogic

func NewGetTosLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTosLogic

Get Tos

func (*GetTosLogic) GetTos

func (l *GetTosLogic) GetTos() (resp *dto.GetTosResponse, err error)

type GlobalConfigSnapshot added in v1.14.19

type GlobalConfigSnapshot struct {
	Site      config.SiteConfig
	Subscribe config.SubscribeConfig
	Email     config.EmailConfig
	Mobile    config.MobileConfig
	Register  config.RegisterConfig
	Verify    config.Verify
	Invite    config.InviteConfig
}

GlobalConfigSnapshot is the public runtime configuration consumed when assembling the global configuration response.

type GlobalConfigStore added in v1.14.19

type GlobalConfigStore interface {
	System() repository.SystemRepo
	Auth() repository.AuthRepo
}

GlobalConfigStore is the persistence surface used by public global configuration reads. It excludes unrelated application repositories.

type HeartbeatLogic added in v1.2.0

type HeartbeatLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewHeartbeatLogic added in v1.2.0

func NewHeartbeatLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HeartbeatLogic

NewHeartbeatLogic Heartbeat

func (*HeartbeatLogic) Heartbeat added in v1.2.0

func (l *HeartbeatLogic) Heartbeat() (resp *dto.HeartbeatResponse, err error)

type SendEmailCodeDependencies added in v1.14.19

type SendEmailCodeDependencies struct {
	Store  VerificationIdentityStore
	Redis  *redis.Client
	Queue  VerificationTaskQueue
	Config EmailCodeConfig
	Policy VerificationCodePolicy
}

SendEmailCodeDependencies explicitly declares the collaborators of email code delivery instead of passing ServiceContext to business logic.

type SendEmailCodeLogic

type SendEmailCodeLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewSendEmailCodeLogic

func NewSendEmailCodeLogic(ctx context.Context, deps SendEmailCodeDependencies) *SendEmailCodeLogic

NewSendEmailCodeLogic Get verification code

func (*SendEmailCodeLogic) SendEmailCode

func (l *SendEmailCodeLogic) SendEmailCode(req *dto.SendCodeRequest) (resp *dto.SendCodeResponse, err error)

type SendSmsCodeDependencies added in v1.14.19

type SendSmsCodeDependencies struct {
	Store  VerificationIdentityStore
	Redis  *redis.Client
	Queue  VerificationTaskQueue
	Config SmsCodeConfig
	Policy VerificationCodePolicy
}

SendSmsCodeDependencies explicitly declares the collaborators of SMS code delivery instead of passing ServiceContext to business logic.

type SendSmsCodeLogic

type SendSmsCodeLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewSendSmsCodeLogic

func NewSendSmsCodeLogic(ctx context.Context, deps SendSmsCodeDependencies) *SendSmsCodeLogic

NewSendSmsCodeLogic Get sms verification code

func (*SendSmsCodeLogic) SendSmsCode

func (l *SendSmsCodeLogic) SendSmsCode(req *dto.SendSmsCodeRequest) (resp *dto.SendCodeResponse, err error)

type SmsCodeConfig added in v1.14.19

type SmsCodeConfig struct {
	VerifyCodeInterval int64
	VerifyCodeLimit    int64
	VerifyCodeExpire   int64
}

SmsCodeConfig is the configuration snapshot consumed by SMS code delivery.

type SmsSendCount

type SmsSendCount struct {
	Count    int64 `json:"count"`
	CreateAt int64 `json:"create_at"`
}

type VerificationCodePolicy added in v1.14.19

type VerificationCodePolicy interface {
	EnsureRegistrationOpen(ctx context.Context, method string) error
	EnsureMethodEnabled(ctx context.Context, method string) error
}

VerificationCodePolicy contains the authentication policy required before issuing a verification code.

type VerificationIdentityStore added in v1.14.19

type VerificationIdentityStore interface {
	UserAuth() repository.UserAuthRepo
}

VerificationIdentityStore is the persistence surface used by verification code delivery. It excludes unrelated application repositories.

type VerificationTaskQueue added in v1.14.19

type VerificationTaskQueue interface {
	Enqueue(task *asynq.Task, opts ...asynq.Option) (*asynq.TaskInfo, error)
}

VerificationTaskQueue publishes verification-code delivery tasks.

Jump to

Keyboard shortcuts

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