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 WithKeyPrefix ¶
WithKeyPrefix redis存验证码key的前缀, 默认 limit:captcha:
type OptionSetter ¶
type OptionSetter interface {
// contains filtered or unexported methods
}
OptionSetter option setter
type QuestionAnswer ¶
QuestionAnswer question and answer for provider
type UnsupportedVerifiedCaptchaDriver ¶
type UnsupportedVerifiedCaptchaDriver struct{}
func (UnsupportedVerifiedCaptchaDriver) GenerateQuestionAnswer ¶
func (x UnsupportedVerifiedCaptchaDriver) GenerateQuestionAnswer() (*QuestionAnswer, error)
func (UnsupportedVerifiedCaptchaDriver) Name ¶
func (x UnsupportedVerifiedCaptchaDriver) Name() string
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) Verify ¶
func (v *VerifiedReflux) Verify(kind, key, uniqueId string) bool
Verify the uniqueId. shortcut Match(id, answer, true)
type VerifiedRefluxProvider ¶
VerifiedRefluxProvider the provider