|
@@ -52,6 +52,7 @@ func RandLightColor(n int) color.RGBA {
|
|
|
}
|
|
|
|
|
|
func Get(sess *httpsession.Session, checkCode string, w http.ResponseWriter, r *http.Request) {
|
|
|
+
|
|
|
code := RandText(4)
|
|
|
log.Println(code)
|
|
|
cacheKey := fmt.Sprintf("captcha_times_%s", sess.Id())
|
|
@@ -104,5 +105,9 @@ func Get(sess *httpsession.Session, checkCode string, w http.ResponseWriter, r *
|
|
|
times++
|
|
|
redis.Put("other", cacheKey, times, int(ttl))
|
|
|
sess.Set(checkCode, code)
|
|
|
+ w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
|
|
+ w.Header().Set("Pragma", "no-cache")
|
|
|
+ w.Header().Set("Expires", "0")
|
|
|
+ w.Header().Set("Content-Type", "image/png")
|
|
|
_ = captchaImage.Encode(w, ImageFormatJpeg)
|
|
|
}
|