package auth import ( "github.com/gin-gonic/gin" v1 "github.com/runningwater/gohub/app/http/controllers/api/v1" "github.com/runningwater/gohub/pkg/captcha" "github.com/runningwater/gohub/pkg/logger" "github.com/runningwater/gohub/pkg/response" ) type VerifyCodeController struct { v1.BaseApiController } // ShowCaptcha 显示图片验证码 func (vc *VerifyCodeController) ShowCaptcha(c *gin.Context) { // 生成验证码 id, b64s, answer, err := captcha.NewCaptcha().GenerateCaptcha() logger.LogIf(err) logger.DebugString("captchaController", "captcha id: ", id) logger.DebugString("captchaController", "captcha answer: ", answer) response.JSON(c, gin.H{ "captcha_id": id, "captcha_image": b64s, }) }