diff --git a/controllers/admin/captcha.go b/controllers/admin/captcha.go index 028630f..b055a99 100644 --- a/controllers/admin/captcha.go +++ b/controllers/admin/captcha.go @@ -104,7 +104,6 @@ func VerifyCaptcha(c *gin.Context, captchaValue string) bool { logrus.WithError(err).Warn("验证码验证失败:无法从Cookie获取captcha_id") return false } - logrus.Infof("VerifyCaptcha: received captchaId=%s, captchaValue=%s", captchaId, captchaValue) // 先尝试原始值验证 if store.Verify(captchaId, captchaValue, false) { diff --git a/utils/cookie.go b/utils/cookie.go index 329ad10..a3b00b7 100644 --- a/utils/cookie.go +++ b/utils/cookie.go @@ -2,6 +2,7 @@ package utils import ( "net/http" + "strings" "time" ) @@ -9,6 +10,20 @@ import ( // Cookie创建函数 // ============================================================================ +// FormatCookies formats a slice of cookies into a string suitable for HTTP headers +func FormatCookies(cookies []*http.Cookie) string { + var b strings.Builder + for i, c := range cookies { + if i > 0 { + b.WriteString("; ") + } + b.WriteString(c.Name) + b.WriteRune('=') + b.WriteString(c.Value) + } + return b.String() +} + // CreateSecureCookie 创建安全的Cookie // name: Cookie名称 // value: Cookie值