fix(server-group): hide guest-empty groups from guest listing

listServerGroup returned every group, including ones whose only
servers are HideForGuest=true (or that have zero members), to
unauthenticated callers. The group name itself is then leaked to
guests even though every server it references is hidden from them.

Guest visitors now only see groups that contain at least one guest-
visible server. Authenticated members and admins keep full visibility
(including their own empty groups) so management UI still works.

Co-authored-by: cloudcode <cloudcode@users.noreply.github.com>
This commit is contained in:
naiba
2026-05-26 04:07:50 +00:00
co-authored by cloudcode
parent 00fde59d4d
commit 76a5e2b261
2 changed files with 125 additions and 0 deletions
+3
View File
@@ -58,6 +58,9 @@ func listServerGroup(c *gin.Context) ([]*model.ServerGroupResponseItem, error) {
if isMember && !isAdmin && !s.HasPermission(c) {
continue
}
if !isMember && len(groupServers[s.ID]) == 0 {
continue
}
sgRes = append(sgRes, &model.ServerGroupResponseItem{
Group: s,
Servers: groupServers[s.ID],