Commit e5ee955f by CalciumIon

fix: token group #477

parent 4a02eb1b
...@@ -41,9 +41,14 @@ func Distribute() func(c *gin.Context) { ...@@ -41,9 +41,14 @@ func Distribute() func(c *gin.Context) {
userGroup, _ := model.CacheGetUserGroup(userId) userGroup, _ := model.CacheGetUserGroup(userId)
tokenGroup := c.GetString("token_group") tokenGroup := c.GetString("token_group")
if tokenGroup != "" { 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 // check group in common.GroupRatio
if _, ok := common.GroupRatio[tokenGroup]; !ok { if _, ok := common.GroupRatio[tokenGroup]; !ok {
abortWithOpenAiMessage(c, http.StatusForbidden, fmt.Sprintf("分组 %s 已被用", tokenGroup)) abortWithOpenAiMessage(c, http.StatusForbidden, fmt.Sprintf("分组 %s 已被用", tokenGroup))
return return
} }
userGroup = tokenGroup userGroup = tokenGroup
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment