验证码存redis
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"git.rosy.net.cn/jx-print/globals"
|
||||
"git.rosy.net.cn/jx-print/model"
|
||||
"github.com/dchest/captcha"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
@@ -65,10 +64,12 @@ func Captcha(c *gin.Context, length ...int) {
|
||||
h = length[2]
|
||||
}
|
||||
captchaId := captcha.NewLen(l)
|
||||
session := sessions.Default(c)
|
||||
session.Set(c.ClientIP()+model.SessionKey, captchaId)
|
||||
_ = session.Save()
|
||||
_ = Serve(c.Writer, c.Request, captchaId, ".png", "zh", false, w, h)
|
||||
//session := sessions.Default(c)
|
||||
//session.Set(c.ClientIP()+model.SessionKey, captchaId)
|
||||
//_ = session.Save()
|
||||
if err := SetKey(c.ClientIP()+model.SessionKey, captchaId, time.Minute*5); err == nil {
|
||||
_ = Serve(c.Writer, c.Request, captchaId, ".png", "zh", false, w, h)
|
||||
}
|
||||
}
|
||||
|
||||
func Serve(w http.ResponseWriter, r *http.Request, id, ext, lang string, download bool, width, height int) error {
|
||||
|
||||
Reference in New Issue
Block a user