| 123456789101112131415161718192021222324252627 |
- 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"
- )
- 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)
- c.JSON(200, gin.H{
- "captcha_id": id,
- "captcha_image": b64s,
- })
- }
|