verifycode

package
v1.15.23 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Service assembly for the verification-code subdomain: issuing and pre-checking the email/SMS codes that gate registration and account mutations. Only the module facade may reach it.

Index

Constants

View Source
const (
	IntervalTime = 60
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckVerificationCodeLogic

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

func (*CheckVerificationCodeLogic) CheckVerificationCode

type Deps

type Deps struct {
	Store  VerificationIdentityStore
	Redis  *redis.Client
	Queue  VerificationTaskQueue
	Policy VerificationCodePolicy
	// Config snapshots the runtime-mutable settings per request.
	Config func() Snapshot
}

Deps declares the subdomain's dependencies; the identity facade forwards them from the composition root and supplies the register policy from the authentication subdomain.

type EmailCodeConfig

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 SendEmailCodeDependencies

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

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 Service

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

Service is the verification-code subdomain entry point used by the identity facade.

func NewService

func NewService(deps Deps) *Service

func (*Service) CheckVerificationCode

func (*Service) SendEmailCode

func (s *Service) SendEmailCode(ctx context.Context, req *dto.SendCodeRequest) (*dto.SendCodeResponse, error)

func (*Service) SendSmsCode

func (s *Service) SendSmsCode(ctx context.Context, req *dto.SendSmsCodeRequest) (*dto.SendCodeResponse, error)

type SmsCodeConfig

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 Snapshot

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

Snapshot is the per-request view of the runtime-mutable settings the verification-code flows consume.

type VerificationCodePolicy

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

type VerificationIdentityStore interface {
	UserAuth() repository.UserAuthRepo
}

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

type VerificationTaskQueue

type VerificationTaskQueue interface {
	EnqueueContext(ctx context.Context, 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