修复验证码验证

This commit is contained in:
xiangheng
2024-06-12 14:49:36 +08:00
parent b45b3654c1
commit 9c53106033
4 changed files with 10 additions and 5 deletions

View File

@@ -85,11 +85,11 @@ func (c *ClickWordCaptchaService) Check(token string, pointJson string) error {
if err != nil {
return err
}
fontsize := c.factory.config.ClickWord.FontSize
fontSize := c.factory.config.ClickWord.FontSize
for i, pointVO := range cachePoint {
targetPoint := userPoint[i]
if targetPoint.X >= pointVO.X-10 && targetPoint.X <= pointVO.X+fontsize+10 && targetPoint.Y >= pointVO.Y-10 && targetPoint.Y <= pointVO.Y+fontsize+10 {
if targetPoint.X >= pointVO.X-10 && targetPoint.X <= pointVO.X+fontSize+10 && targetPoint.Y >= pointVO.Y-10 && targetPoint.Y <= pointVO.Y+fontSize+10 {
} else {
return errors.New("验证失败")

View File

@@ -31,7 +31,8 @@ type ImageUtil struct {
func NewImageUtil(src string, fontPath string) *ImageUtil {
srcImage := OpenPngImage(src)
return &ImageUtil{Src: src,
return &ImageUtil{
Src: src,
SrcImage: srcImage,
RgbaImage: ImageToRGBA(srcImage),
Width: srcImage.Bounds().Dx(),