验证码存redis
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"git.rosy.net.cn/jx-print/model"
|
||||
"git.rosy.net.cn/jx-print/utils"
|
||||
"github.com/dchest/captcha"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -93,10 +92,9 @@ func callFunc(c *gin.Context, worker func() (retVal interface{}, errCode string,
|
||||
}
|
||||
|
||||
func captchaVerify(c *gin.Context, code string) bool {
|
||||
session := sessions.Default(c)
|
||||
if captchaId := session.Get(c.ClientIP() + model.SessionKey); captchaId != nil {
|
||||
session.Delete(c.ClientIP() + model.SessionKey)
|
||||
_ = session.Save()
|
||||
//session := sessions.Default(c)
|
||||
if captchaId := utils.GetKet(c.ClientIP() + model.SessionKey); captchaId != nil {
|
||||
utils.DelKey(c.ClientIP() + model.SessionKey)
|
||||
if captcha.VerifyString(captchaId.(string), code) {
|
||||
return true
|
||||
} else {
|
||||
@@ -105,6 +103,17 @@ func captchaVerify(c *gin.Context, code string) bool {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
//if captchaId := session.Get(c.ClientIP() + model.SessionKey); captchaId != nil {
|
||||
// session.Delete(c.ClientIP() + model.SessionKey)
|
||||
// _ = session.Save()
|
||||
// if captcha.VerifyString(captchaId.(string), code) {
|
||||
// return true
|
||||
// } else {
|
||||
// return false
|
||||
// }
|
||||
//} else {
|
||||
// return false
|
||||
//}
|
||||
}
|
||||
|
||||
func buildErrJson(c *gin.Context, err error) {
|
||||
|
||||
Reference in New Issue
Block a user