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. 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