diff --git a/controllers/controller.go b/controllers/controller.go index 4b38e67..860e6ad 100644 --- a/controllers/controller.go +++ b/controllers/controller.go @@ -26,7 +26,6 @@ func checkToken(c *gin.Context) (tokenInfo *model.TokenInfo) { var ( cookie *http.Cookie err error - ok bool token string user *model.User ) @@ -105,9 +104,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 := utils.GetKet(c.ClientIP() + model.SessionKey); captchaId != nil { + if captchaId := utils.GetKey(c.ClientIP() + model.SessionKey); captchaId != "" { utils.DelKey(c.ClientIP() + model.SessionKey) - if captcha.VerifyString(captchaId.(string), code) { + if captcha.VerifyString(captchaId, code) { return true } else { return false diff --git a/services/app.go b/services/app.go index 3ae489e..482f8e8 100644 --- a/services/app.go +++ b/services/app.go @@ -23,9 +23,9 @@ func AddApp(c *gin.Context, code, name, mobile, userID string) (err error) { db = globals.GetDB() now = time.Now() ) - if rcode, ok := putils.GetKet(mobile).(string); !ok { + if rcode := putils.GetKey(mobile); rcode == "" { putils.DelKey(mobile) - return err + return fmt.Errorf("验证码错误!") } else if code != rcode { putils.DelKey(mobile) return fmt.Errorf("验证码错误!")