This commit is contained in:
suyl
2021-07-23 14:11:59 +08:00
parent 215bf52530
commit 5d6e5582aa
16 changed files with 166 additions and 24 deletions

View File

@@ -5,8 +5,8 @@ import (
"fmt"
"git.rosy.net.cn/jx-print/globals"
"git.rosy.net.cn/jx-print/model"
"git.rosy.net.cn/jx-print/putils"
"git.rosy.net.cn/jx-print/services"
"git.rosy.net.cn/jx-print/utils"
"github.com/dchest/captcha"
"github.com/gin-gonic/gin"
"net/http"
@@ -44,7 +44,7 @@ func checkToken(c *gin.Context) (tokenInfo *model.TokenInfo) {
tokenInfo.Token = cookie.Value
}
globals.SugarLogger.Debugf("checkToken token: %v", tokenInfo.Token)
if tokenMap = utils.GetKey(tokenInfo.Token).(map[string]interface{}); tokenMap == nil {
if tokenMap = putils.GetKey(tokenInfo.Token).(map[string]interface{}); tokenMap == nil {
err = fmt.Errorf("token过期或无效请重新登录")
c.JSON(http.StatusOK, &CallBack{
Desc: err.Error(),
@@ -63,7 +63,7 @@ func checkToken(c *gin.Context) (tokenInfo *model.TokenInfo) {
})
return nil
}
globals.SugarLogger.Debugf("checkToken user: %v", utils.Format4Output(user, true))
globals.SugarLogger.Debugf("checkToken user: %v", putils.Format4Output(user, true))
}
return tokenInfo
}
@@ -106,8 +106,8 @@ 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).(string); captchaId != "" {
utils.DelKey(c.ClientIP() + model.SessionKey)
if captchaId := putils.GetKey(c.ClientIP() + model.SessionKey).(string); captchaId != "" {
putils.DelKey(c.ClientIP() + model.SessionKey)
if captcha.VerifyString(captchaId, code) {
return true
} else {