Skip to content

Commit 5a075a2

Browse files
committed
fix: members only groups
1 parent 7da37b4 commit 5a075a2

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

backend/open_webui/models/groups.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,15 @@ def get_groups(self, filter, db: Optional[Session] = None) -> list[GroupResponse
165165
share_value = filter["share"]
166166
member_id = filter.get("member_id")
167167
json_share = Group.data["config"]["share"]
168-
json_share_bool = json_share.as_boolean()
169-
json_share_str = json_share.as_string()
168+
json_share_lower = func.lower(json_share.as_string())
170169

171170
if share_value:
172-
# Groups open to anyone: data is null, share is null, or share is true
171+
# Groups open to anyone: data is null, config.share is null, or share is true
172+
# Use case-insensitive string comparison to handle variations like "True", "TRUE"
173173
anyone_can_share = or_(
174174
Group.data.is_(None),
175-
json_share_bool.is_(None),
176-
json_share_bool == True,
175+
json_share_lower.is_(None),
176+
json_share_lower == "true",
177177
)
178178

179179
if member_id:
@@ -184,7 +184,7 @@ def get_groups(self, filter, db: Optional[Session] = None) -> list[GroupResponse
184184
.subquery()
185185
)
186186
members_only_and_is_member = and_(
187-
json_share_str == "members",
187+
json_share_lower == "members",
188188
Group.id.in_(member_groups_subq),
189189
)
190190
query = query.filter(
@@ -194,7 +194,7 @@ def get_groups(self, filter, db: Optional[Session] = None) -> list[GroupResponse
194194
query = query.filter(anyone_can_share)
195195
else:
196196
query = query.filter(
197-
and_(Group.data.isnot(None), json_share_bool == False)
197+
and_(Group.data.isnot(None), json_share_lower == "false")
198198
)
199199

200200
else:

src/lib/components/workspace/common/AccessControl.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
};
4343
4444
onMount(async () => {
45-
groups = await getGroups(localStorage.token, true);
45+
groups = await getGroups(localStorage.token, true).catch((error) => {
46+
console.error(error);
47+
return [];
48+
});
4649
4750
if (accessControl === null) {
4851
initPublicAccess();

src/lib/components/workspace/common/MemberSelector.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@
6565
}
6666
6767
onMount(async () => {
68-
groups = await getGroups(localStorage.token, true);
68+
groups = await getGroups(localStorage.token, true).catch((error) => {
69+
console.error(error);
70+
return [];
71+
});
72+
6973
if (userIds.length > 0) {
7074
userIds.forEach(async (id) => {
7175
const res = await getUserById(localStorage.token, id).catch((error) => {

0 commit comments

Comments
 (0)