Skip to content

[DATAVIC-953] hide add new member button and added auth function#309

Open
awset wants to merge 1 commit intouatfrom
feature/DATAVIC-953
Open

[DATAVIC-953] hide add new member button and added auth function#309
awset wants to merge 1 commit intouatfrom
feature/DATAVIC-953

Conversation

@awset
Copy link
Copy Markdown
Collaborator

@awset awset commented Apr 26, 2026

https://digital-vic.atlassian.net/browse/DATAVIC-953

changes

  • added new chained action to prevent user visiting the member add page
  • added theme override to hide the button

@awset awset requested a review from MarkCalvert April 26, 2026 16:10
@awset awset self-assigned this Apr 26, 2026
return {"success": False}

@tk.chained_auth_function
def organization_member_create(next_auth, context, data_dict):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a tip with auth functions in CKAN.
If the auth check is only to allow sysadmin access, all the auth function needs to do is return {'success': False}.
This is because when the CKAN helper check_access is used, it includes logic that skips the auth check for sysadmin users in ckan.authz.is_authorized (which ckan.plugins.toolkit.check_access uses).
As long as the auth function does not use @auth_sysadmins_check docstring in ckan/logic/init.py)
This means only non-sysadmin users would reach this code and we can just return false with a optional message.


{% block page_primary_action %}
{% if h.check_access('organization_update', {'id': organization.id}) %}
{% if g.userobj.sysadmin %}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is absolutely fine because it is inside the above if check_access, but be aware that g.userobj is '' for anonymous users.
Just a FYI, another way to check sysadmin user access is h.check_access('sysadmin').
Both work fine and are just a preference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants