Kaynağa Gözat

修改pc端网站登录漏洞

hongze 5 ay önce
ebeveyn
işleme
cd6785f03b

+ 11 - 9
controller/response/base.go

@@ -5,16 +5,15 @@ import (
 	"fmt"
 	"github.com/gin-gonic/gin"
 	"hongze/hongze_yb/global"
-	"hongze/hongze_yb/utils"
 	"strings"
 )
 
 var (
-	OK_CODE            = 200  //业务成功
-	FAIL_CODE          = 400  //业务错误
-	TOKEN_ERROR_CODE   = 401  //toke异常
-	NO_AUTH            = 403  //没有权限
-	SPECIFIC_FAIL_CODE = 4001 // 业务指定错误
+	OK_CODE                 = 200  //业务成功
+	FAIL_CODE               = 400  //业务错误
+	TOKEN_ERROR_CODE        = 401  //toke异常
+	NO_AUTH                 = 403  //没有权限
+	SPECIFIC_FAIL_CODE      = 4001 // 业务指定错误
 	REPORT_NOT_RELEASE_CODE = 4002 // 报告未发布错误
 )
 
@@ -50,9 +49,12 @@ func result(code int, resultData ResultData, c *gin.Context) {
 		global.LOG.Info(strings.Join(logSlice, ";"))
 		c.JSON(code, resultData)
 	} else {
+		//global.LOG.Info(strings.Join(logSlice, ";"))
+		//encryptResult := utils.DesBase64Encrypt(jsonByte)
+		//c.JSON(code, string(encryptResult))
+
 		global.LOG.Info(strings.Join(logSlice, ";"))
-		encryptResult := utils.DesBase64Encrypt(jsonByte)
-		c.JSON(code, string(encryptResult))
+		c.JSON(code, resultData)
 	}
 	c.Abort()
 }
@@ -174,4 +176,4 @@ func NotReleaseMsg(msg, errMsg string, c *gin.Context) {
 		ErrMsg: errMsg,
 	}
 	result(200, resultData, c)
-}
+}

+ 3 - 2
models/tables/rddp/session/query.go

@@ -3,6 +3,7 @@ package session
 import (
 	"gorm.io/gorm"
 	"hongze/hongze_yb/global"
+	"hongze/hongze_yb/utils"
 	"time"
 )
 
@@ -25,6 +26,6 @@ func getDb() *gorm.DB {
 
 // GetTokenByUid 根据用户id获取token
 func GetTokenByUid(userId int) (item *Session, err error) {
-	err = getDb().Where("user_id = ? ", userId).First(&item).Error
+	err = getDb().Where("user_id = ? AND expire_time > ? ", userId, time.Now().Format(utils.FormatDateTime)).Order("session_id DESC").First(&item).Error
 	return
-}
+}