verified

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GenerateOption

type GenerateOption func(GenerateOptionSetter)

GenerateOption generate option

func WithGenerateKeyExpires

func WithGenerateKeyExpires(t time.Duration) GenerateOption

WithGenerateKeyExpires redis存验证码key的过期时间

type GenerateOptionSetter

type GenerateOptionSetter interface {
	// contains filtered or unexported methods
}

GenerateOptionSetter generate option setter

type Option

type Option func(OptionSetter)

Option 选项

func WithKeyExpires

func WithKeyExpires(t time.Duration) Option

WithKeyExpires redis存验证码key的过期时间

func WithKeyPrefix

func WithKeyPrefix(k string) Option

WithKeyPrefix redis存验证码key的前缀, 默认 limit:captcha:

type OptionSetter

type OptionSetter interface {
	// contains filtered or unexported methods
}

OptionSetter option setter

type QuestionAnswer

type QuestionAnswer struct {
	Id       string
	Question string
	Answer   string
}

QuestionAnswer question and answer for provider

type UnsupportedVerifiedCaptchaDriver

type UnsupportedVerifiedCaptchaDriver struct{}

func (UnsupportedVerifiedCaptchaDriver) GenerateQuestionAnswer

func (x UnsupportedVerifiedCaptchaDriver) GenerateQuestionAnswer() (*QuestionAnswer, error)

func (UnsupportedVerifiedCaptchaDriver) Name

type VerifiedCaptcha

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

VerifiedCaptcha verified captcha limit

func NewVerifiedCaptcha

func NewVerifiedCaptcha(p VerifiedCaptchaProvider, store *redis.Client, opts ...Option) *VerifiedCaptcha

NewVerifiedCaptcha

func (*VerifiedCaptcha) Generate

func (v *VerifiedCaptcha) Generate(kind string, opts ...GenerateOption) (id, question string, err error)

Generate generate id, question. use GenerateOption overwrite default key expires

func (*VerifiedCaptcha) Match

func (v *VerifiedCaptcha) Match(kind, id, answer string, clear bool) bool

Match the answer. if clear is true, it will remove from store

func (*VerifiedCaptcha) Name

func (v *VerifiedCaptcha) Name(kind string) string

Name the provider name

func (*VerifiedCaptcha) Verify

func (v *VerifiedCaptcha) Verify(kind, id, answer string) bool

Verify the answer. shortcut Match(id, answer, true)

type VerifiedCaptchaDriver

type VerifiedCaptchaDriver interface {
	Name() string
	GenerateQuestionAnswer() (*QuestionAnswer, error)
}

VerifiedCaptchaDriver the driver

type VerifiedCaptchaProvider

type VerifiedCaptchaProvider interface {
	AcquireDriver(kind string) VerifiedCaptchaDriver
}

VerifiedCaptchaProvider the provider

type VerifiedReflux

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

VerifiedReflux verified captcha limit

func NewVerifiedReflux

func NewVerifiedReflux(p VerifiedRefluxProvider, store *redis.Client, opts ...Option) *VerifiedReflux

NewVerifiedReflux

func (*VerifiedReflux) Generate

func (v *VerifiedReflux) Generate(kind, key string, opts ...GenerateOption) (string, error)

Generate generate uniqueId. use GenerateOption overwrite default key expires

func (*VerifiedReflux) Match

func (v *VerifiedReflux) Match(kind, key, uniqueId string, clear bool) bool

Match the uniqueId. if clear is true, it will remove from store

func (*VerifiedReflux) Name

func (v *VerifiedReflux) Name() string

Name the provider name

func (*VerifiedReflux) Verify

func (v *VerifiedReflux) Verify(kind, key, uniqueId string) bool

Verify the uniqueId. shortcut Match(id, answer, true)

type VerifiedRefluxProvider

type VerifiedRefluxProvider interface {
	Name() string
	GenerateUniqueId() string
}

VerifiedRefluxProvider the provider

Jump to

Keyboard shortcuts

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