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的过期时间
func WithGenerateMaxErrQuota ¶ added in v0.1.1
func WithGenerateMaxErrQuota(quota int) GenerateOption
WithGenerateMaxErrQuota 设置最大错误验证次数 NOTE: 仅禁用一次性验证器时, 该功能有效
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:
func WithMaxErrQuota ¶ added in v0.1.1
SetMaxErrQuota 设置最大错误次数验证, 并禁用一次性验证 NOTE: 并设置最大错误次数验证, 将禁用一次性验证(默认验证器一次性有效)
type OptionSetter ¶
type OptionSetter interface {
// contains filtered or unexported methods
}
OptionSetter option setter
type QuestionAnswer ¶
QuestionAnswer question and answer for driver
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.
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) Verify ¶
func (v *VerifiedReflux) Verify(kind, key, uniqueId string) bool
Verify the uniqueId. shortcut Match(id, answer, true)
type VerifiedRefluxProvider ¶
VerifiedRefluxProvider the provider