diff options
| author | Frederick Muriuki Muriithi | 2026-02-10 11:21:55 -0600 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-02-10 11:27:38 -0600 |
| commit | 2fe5d90776edd1bc62a6eeaa492d3efb2974b158 (patch) | |
| tree | 7c4fc0ea5d7723167fdfa2948b60f4b0dad3dbf1 /gn_auth/auth/authorisation/resources | |
| parent | 5d0c7b9f0a811e1b777285f4f7de59db8deeb14c (diff) | |
| download | gn-auth-2fe5d90776edd1bc62a6eeaa492d3efb2974b158.tar.gz | |
Use Auth function that checks for delete access.
Diffstat (limited to 'gn_auth/auth/authorisation/resources')
| -rw-r--r-- | gn_auth/auth/authorisation/resources/views.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/gn_auth/auth/authorisation/resources/views.py b/gn_auth/auth/authorisation/resources/views.py index a960ca3..e4401c5 100644 --- a/gn_auth/auth/authorisation/resources/views.py +++ b/gn_auth/auth/authorisation/resources/views.py @@ -39,12 +39,14 @@ from gn_auth.auth.authorisation.roles.models import ( from gn_auth.auth.authentication.oauth2.resource_server import require_oauth from gn_auth.auth.authentication.users import User, user_by_id, user_by_email +from .system.models import system_resource + from .inbredset.views import popbp from .genotypes.views import genobp from .phenotypes.views import phenobp from .errors import MissingGroupError from .groups.models import Group, user_group -from .checks import authorised_for, authorised_for_spec +from .checks import can_delete, authorised_for from .models import ( Resource, resource_data, resource_by_id, public_resources, resource_categories, assign_resource_user, link_data_to_resource, @@ -685,13 +687,9 @@ def delete_resource(): form = request_json() try: resource_id = UUID(form.get("resource_id")) - if not authorised_for_spec( - conn, - the_token.user.user_id, - resource_id, - "(OR group:resource:delete-resource system:resource:delete)"): - raise AuthorisationError("You do not have the appropriate " - "privileges to delete this resource.") + if not can_delete(conn, the_token.user.user_id, resource_id): + raise AuthorisationError( + "You are not allowed to delete this resource.") data = resource_data( conn, |
