mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-17 16:06:38 +08:00
fix: playground group
This commit is contained in:
parent
e298f2e5a4
commit
6a8a4bcf65
@ -21,3 +21,8 @@ func UpdateUserUsableGroupsByJSONString(jsonStr string) error {
|
|||||||
UserUsableGroups = make(map[string]string)
|
UserUsableGroups = make(map[string]string)
|
||||||
return json.Unmarshal([]byte(jsonStr), &UserUsableGroups)
|
return json.Unmarshal([]byte(jsonStr), &UserUsableGroups)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GroupInUserUsableGroups(groupName string) bool {
|
||||||
|
_, ok := UserUsableGroups[groupName]
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
@ -68,9 +68,15 @@ func Playground(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
c.Set("original_model", playgroundRequest.Model)
|
c.Set("original_model", playgroundRequest.Model)
|
||||||
group := playgroundRequest.Group
|
group := playgroundRequest.Group
|
||||||
|
userGroup := c.GetString("group")
|
||||||
|
|
||||||
if group == "" {
|
if group == "" {
|
||||||
group = c.GetString("group")
|
group = userGroup
|
||||||
} else {
|
} else {
|
||||||
|
if !common.GroupInUserUsableGroups(group) && group != userGroup {
|
||||||
|
openaiErr = service.OpenAIErrorWrapperLocal(errors.New("无权访问该分组"), "group_not_allowed", http.StatusForbidden)
|
||||||
|
return
|
||||||
|
}
|
||||||
c.Set("group", group)
|
c.Set("group", group)
|
||||||
}
|
}
|
||||||
c.Set("token_name", "playground-"+group)
|
c.Set("token_name", "playground-"+group)
|
||||||
|
Loading…
Reference in New Issue
Block a user