Versions in this module Expand all Collapse all v1 v1.1.0 Apr 15, 2016 Changes in this version + const DefaultCodeLen + 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 + CodeLen int + type DataItem struct + Code string + CreateTime time.Time + Email string + Expire time.Duration + ID int64 type MemoryStore + func (this *MemoryStore) TakeByEmailAndCode(email, code string) (*DataItem, error) + func (this *MemoryStore) TakeByID(id int64) (*DataItem, error) type Store + TakeByEmailAndCode func(email, code string) (*DataItem, error) + TakeByID func(id int64) (*DataItem, error) + 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) v1.0.1 Apr 15, 2016 Changes in this version + const DefaultExpire + const DefaultMemoryGCInterval + const DefaultRandomCodeLen + type Config struct + Expire time.Duration + RandomCodeLen int + type Manager struct + func NewManager(store Store, cfg ...Config) *Manager + func (this *Manager) GenerateToken(email string) (string, error) + func (this *Manager) Validate(token string) (isValid bool, email string, err error) + type MemoryStore struct + func (this *MemoryStore) Put(item *StoreItem) (int64, error) + func (this *MemoryStore) Take(id int64) (*StoreItem, error) + type Store interface + Put func(item *StoreItem) (int64, error) + Take func(id int64) (*StoreItem, error) + func NewMemoryStore(gcInterval time.Duration) Store + type StoreItem struct + Email string + Expire time.Duration + Time time.Time + ValidateCode string