Browse Source

fixed bug.

zhou.xiaoning 1 year ago
parent
commit
a4f3caf2c1
1 changed files with 6 additions and 5 deletions
  1. 6 5
      token/token.go

+ 6 - 5
token/token.go

@@ -105,13 +105,14 @@ func Auth() gin.HandlerFunc {
 			c.Set("requserid", userID)
 		}
 
+		// 是否已开启APIKey检验模式
 		if config.SerCfg.GetApiKeyMode() {
 			timestamp := c.GetHeader("Timestamp")
 			verification := c.GetHeader("Verification")
 			if timestamp == "" || token == "" || verification == "" {
 				c.JSON(http.StatusUnauthorized, gin.H{
 					"code": e.ERROR,
-					"msg":  "apikey1",
+					"msg":  "apikey_err1",
 					"data": struct{}{},
 				})
 
@@ -124,7 +125,7 @@ func Auth() gin.HandlerFunc {
 			if err != nil {
 				c.JSON(http.StatusUnauthorized, gin.H{
 					"code": e.ERROR,
-					"msg":  "apikey2",
+					"msg":  "apikey_err2",
 					"data": struct{}{},
 				})
 
@@ -137,7 +138,7 @@ func Auth() gin.HandlerFunc {
 			if ts < -10*1000 || ts > 10*1000 {
 				c.JSON(http.StatusUnauthorized, gin.H{
 					"code": e.ERROR,
-					"msg":  "apikey3",
+					"msg":  "apikey_err3",
 					"data": struct{}{},
 				})
 
@@ -152,7 +153,7 @@ func Auth() gin.HandlerFunc {
 			if h == "" {
 				c.JSON(http.StatusUnauthorized, gin.H{
 					"code": e.ERROR,
-					"msg":  "apikey4",
+					"msg":  "apikey_err4",
 					"data": struct{}{},
 				})
 
@@ -162,7 +163,7 @@ func Auth() gin.HandlerFunc {
 			if h != verification {
 				c.JSON(http.StatusUnauthorized, gin.H{
 					"code": e.ERROR,
-					"msg":  "apikey5",
+					"msg":  "apikey_err5",
 					"data": struct{}{},
 				})