From 3fbdd502b66ebbdaf758543c142209b6eec80af5 Mon Sep 17 00:00:00 2001 From: CalciumIon <1808837298@qq.com> Date: Wed, 18 Sep 2024 18:55:11 +0800 Subject: [PATCH] fix: token group #477 --- middleware/distributor.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/middleware/distributor.go b/middleware/distributor.go index 0393d24f6..7a9596498 100644 --- a/middleware/distributor.go +++ b/middleware/distributor.go @@ -41,9 +41,14 @@ func Distribute() func(c *gin.Context) { userGroup, _ := model.CacheGetUserGroup(userId) tokenGroup := c.GetString("token_group") if tokenGroup != "" { + // check common.UserUsableGroups[userGroup] + if _, ok := common.UserUsableGroups[tokenGroup]; !ok { + abortWithOpenAiMessage(c, http.StatusForbidden, fmt.Sprintf("令牌分组 %s 已被禁用", tokenGroup)) + return + } // check group in common.GroupRatio if _, ok := common.GroupRatio[tokenGroup]; !ok { - abortWithOpenAiMessage(c, http.StatusForbidden, fmt.Sprintf("分组 %s 已被禁用", tokenGroup)) + abortWithOpenAiMessage(c, http.StatusForbidden, fmt.Sprintf("分组 %s 已被弃用", tokenGroup)) return } userGroup = tokenGroup