captcha: fix missing images

The captcha library's data struct wasn't being serialized/deserialized
fully, meaning the image was never stored. I never really wanted it to
be stored anyway, but as a compromise, the invite daemon now deletes
captcha images from the DB 20 minutes after generation.
This commit is contained in:
Harvey Tindall
2023-09-07 22:38:23 +01:00
parent 4607a30e6a
commit a0f1cd5814
3 changed files with 48 additions and 18 deletions
+7 -2
View File
@@ -11,7 +11,6 @@ import (
"time"
"github.com/hrfee/mediabrowser"
"github.com/steambap/captcha"
"github.com/timshannon/badgerhold/v4"
)
@@ -501,12 +500,18 @@ type Invite struct {
Notify map[string]map[string]bool `json:"notify"`
Profile string `json:"profile"`
Label string `json:"label,omitempty"`
Captchas map[string]*captcha.Data // Map of Captcha IDs to answers
Captchas map[string]Captcha // Map of Captcha IDs to images & answers
IsReferral bool `json:"is_referral" badgerhold:"index"`
ReferrerJellyfinID string `json:"referrer_id"`
ReferrerTemplateForProfile string
}
type Captcha struct {
Answer string
Image []byte // image/png
Generated time.Time
}
type Lang struct {
AdminPath string
chosenAdminLang string