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