Versions in this module Expand all Collapse all v1 v1.3.1 Sep 7, 2023 Changes in this version + const DefaultCodeLen + const DefaultExpire + const DefaultGCInterval + type CodeValidate struct + func NewCodeValidate(store Store, cfg ...Config) *CodeValidate + func (this *CodeValidate) Generate(email string) (string, error) + func (this *CodeValidate) Validate(email, code string) (isValid bool, err error) + type Config struct + CodeLen int + CodeType int + Expire time.Duration + type DataItem struct + Code string + CreateTime time.Time + Email string + Expire time.Duration + ID int64 + type MemoryStore struct + func (this *MemoryStore) Put(item DataItem) (int64, error) + func (this *MemoryStore) TakeByEmailAndCode(email, code string) (*DataItem, error) + func (this *MemoryStore) TakeByID(id int64) (*DataItem, error) + type Store interface + Put func(item DataItem) (int64, error) + TakeByEmailAndCode func(email, code string) (*DataItem, error) + TakeByID func(id int64) (*DataItem, error) + func NewMemoryStore(gcInterval time.Duration) Store + type TokenValidate struct + func NewTokenValidate(store Store, cfg ...Config) *TokenValidate + func (this *TokenValidate) Generate(email string) (string, error) + func (this *TokenValidate) Validate(token string) (isValid bool, email string, err error)