From efd3bd91a06ed9ce1003245a921ba426ea185491 Mon Sep 17 00:00:00 2001 From: tino097 Date: Fri, 20 Sep 2024 18:12:38 +0200 Subject: [PATCH 1/2] [8438] Put the member_list method in try block and return 0 when not Authorized --- ckan/lib/helpers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py index 7f587de6ca5..6001c6c47ae 100644 --- a/ckan/lib/helpers.py +++ b/ckan/lib/helpers.py @@ -2018,7 +2018,10 @@ def member_count(group: str) -> int: u'id': group, u'object_type': u'user' } - return len(logic.get_action(u'member_list')(context, data_dict)) + try: + return len(logic.get_action(u'member_list')(context, data_dict)) + except logic.NotAuthorized: + return 0 @core_helper From 8335e4d99aa92fc5d39599c3a9ed1090011b2d91 Mon Sep 17 00:00:00 2001 From: tino097 Date: Thu, 26 Sep 2024 16:00:44 +0200 Subject: [PATCH 2/2] Add changelog entry --- changes/8438.bugfix | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changes/8438.bugfix diff --git a/changes/8438.bugfix b/changes/8438.bugfix new file mode 100644 index 00000000000..331b7017ccd --- /dev/null +++ b/changes/8438.bugfix @@ -0,0 +1,2 @@ +Template helper `member_count` will return 0 +for unauthorized users.