package app

import (
	"github.com/go-redis/redis/v8"
	"github.com/mojocn/base64Captcha"
	"gofiber.study.skcks.cn/common/config"
	"gofiber.study.skcks.cn/global"
)

var Store *global.CaptchaStore

func reloadCaptcha(c *config.BasicConfig, redis *redis.Client) {
	driver := &base64Captcha.DriverString{
		Height: c.Captcha.Height,
		Width:  c.Captcha.Width,

		NoiseCount: c.Captcha.NoiseCount,
		Fonts: []string{
			"SourceHanSansCN-VF-2.otf",
		},
		ShowLineOptions: c.Captcha.ShowLineOptions,
		Length:          c.Captcha.Length,
		Source:          c.Captcha.Source,
		BgColor:         c.Captcha.BgColor,
	}

	Store = global.NewCaptchaStore(redis)
	global.Captcha = base64Captcha.NewCaptcha(driver, Store)
}
