captchaDb is now of type CaptchaDB interface. Use a constructor for InMemoryCaptchaDB.

A new captcha is now being created here instead of passed as an argument.
This commit is contained in:
Alexander Andreev 2022-08-19 02:09:01 +04:00
parent 517ebb1689
commit 916b85500d
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -6,15 +6,15 @@ import (
"time" "time"
) )
var captchaDb captcha.InMemoryCaptchaDB = captcha.InMemoryCaptchaDB{ var captchaDb captcha.CaptchaDB
DB: make(map[captcha.ID]captcha.Captcha)}
func Init(expiry time.Duration) { func Init(expiry time.Duration) {
captchaDb.SetExpiry(expiry) captchaDb = captcha.NewInMemoryCaptchaDB(expiry)
} }
func New(data string, captcha captcha.Captcha) (captcha.Captcha, captcha.ID) { func New(data string) (captcha.Captcha, captcha.ID) {
return captchaDb.New(data, captcha) dc := NewDwellingCaptcha(captchaDb.GetExpiry())
return captchaDb.New(data, dc)
} }
func Image(id captcha.ID, style string) (*image.Image, error) { func Image(id captcha.ID, style string) (*image.Image, error) {