aa
This commit is contained in:
@@ -43,7 +43,7 @@ func checkToken(c *gin.Context) (tokenInfo *model.TokenInfo) {
|
||||
tokenInfo.Token = cookie.Value
|
||||
}
|
||||
globals.SugarLogger.Debugf("checkToken token1: %v", tokenInfo.Token)
|
||||
if token = utils.GetKey(tokenInfo.Token); token == "" {
|
||||
if token = utils.GetKey(tokenInfo.Token).(string); token == "" {
|
||||
err = fmt.Errorf("token过期或无效,请重新登录!")
|
||||
c.JSON(http.StatusOK, &CallBack{
|
||||
Desc: err.Error(),
|
||||
@@ -104,7 +104,7 @@ 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.GetKey(c.ClientIP() + model.SessionKey); captchaId != "" {
|
||||
if captchaId := utils.GetKey(c.ClientIP() + model.SessionKey).(string); captchaId != "" {
|
||||
utils.DelKey(c.ClientIP() + model.SessionKey)
|
||||
if captcha.VerifyString(captchaId, code) {
|
||||
return true
|
||||
|
||||
@@ -34,10 +34,13 @@ func DelKey(key string) error {
|
||||
return client.Del(key).Err()
|
||||
}
|
||||
|
||||
func GetKey(key string) string {
|
||||
func GetKey(key string) interface{} {
|
||||
result, err := client.Get(key).Result()
|
||||
if err == nil {
|
||||
return result
|
||||
var retVal interface{}
|
||||
if err = utils.UnmarshalUseNumber([]byte(result), &retVal); err == nil {
|
||||
return retVal
|
||||
}
|
||||
}
|
||||
return ""
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user