Documentation ¶
Index ¶
- func CheckCaptcha(key, dots string) error
- func EmailCaptchaVerify(email, code string) bool
- func GenEmailCaptcha(email string) (code string, err error)
- func Init(rds redis.Cmdable, stroeTyp StoreTyp)
- func NewMemoryStore(collectNum int, expiration time.Duration) *memoryStore
- func PicVerify(id, answer string) (match bool)
- func SetStoreType(typ StoreTyp)
- type DotsCaptcha
- type PicCaptcha
- type PicCaptchaIf
- type Store
- type StoreTyp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckCaptcha ¶
func EmailCaptchaVerify ¶
func GenEmailCaptcha ¶
func NewMemoryStore ¶
NewMemoryStore returns a new standard memory store for captchas with the given collection threshold and expiration time (duration). The returned store must be registered with SetCustomStore to replace the default one.
func SetStoreType ¶
func SetStoreType(typ StoreTyp)
Types ¶
type DotsCaptcha ¶
func GetActCaptcha ¶
func GetActCaptcha() (*DotsCaptcha, error)
type PicCaptcha ¶
func GetPicCaptcha ¶
func GetPicCaptcha() (res *PicCaptcha, err error)
type PicCaptchaIf ¶
type PicCaptchaIf interface { GenerateIdQuestionAnswer() (id, question, answer string) DrawCaptcha(question string) (item base64Captcha.Item, err error) }
type Store ¶
type Store interface { // Set sets the digits for the captcha id. Set(id string, digits interface{}) // Get returns stored digits for the captcha id. Clear indicates // whether the captcha must be deleted from the store. Get(id string, clear bool) (digits interface{}) }
An object implementing Store interface can be registered with SetCustomStore function to handle storage and retrieval of captcha ids and solutions for them, replacing the default memory store.
It is the responsibility of an object to delete expired and used captchas when necessary (for example, the default memory store collects them in Set method after the certain amount of captchas has been stored.)
Click to show internal directories.
Click to hide internal directories.