fix(groups): 匿名请求公开分组接口时跳过用户分组查询 (#8461) (#8463)

This commit is contained in:
Nick Old authored and GitHub committed 2026-11-27 18:13:13 +08:00
1 parent 81c1fd20ef
commit fde819b05a
1 file changed
+4 -2
+4 -2
View File
@@ -26,8 +26,10 @@ func GetGroups(c *gin.Context) {
func GetUserGroups(c *gin.Context) {
usableGroups := make(map[string]map[string]any)
userGroup := ""
userId := c.GetInt("id")
userGroup, _ = model.GetUserGroup(userId, false)
// /api/user/groups is public, so anonymous requests have no user id and use the public groups
if userId := c.GetInt("id"); userId > 0 {
userGroup, _ = model.GetUserGroup(userId, false)
}
userUsableGroups := service.GetUserUsableGroups(userGroup)
for groupName, _ := range ratio_setting.GetGroupRatioCopy() {
// UserUsableGroups contains the groups that the user can use