From fde819b05adfb057059f5efddf24b74fbdf97160 Mon Sep 17 00:00:00 2001 From: Nick Old Date: Fri, 27 Nov 2026 18:13:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(groups):=20=E5=8C=BF=E5=90=8D=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=85=AC=E5=BC=80=E5=88=86=E7=BB=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=97=B6=E8=B7=B3=E8=BF=87=E7=94=A8=E6=88=B7=E5=88=86=E7=BB=84?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=20(#8461)=20(#8463)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/group.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controller/group.go b/controller/group.go index fc418139b1..7497571291 100644 --- a/controller/group.go +++ b/controller/group.go @@ -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