diff options
| -rw-r--r-- | gn_auth/auth/authorisation/resources/common.py | 2 | ||||
| -rw-r--r-- | gn_auth/auth/authorisation/resources/models.py | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/gn_auth/auth/authorisation/resources/common.py b/gn_auth/auth/authorisation/resources/common.py index 0c12fe1..13a0c87 100644 --- a/gn_auth/auth/authorisation/resources/common.py +++ b/gn_auth/auth/authorisation/resources/common.py @@ -1,7 +1,7 @@ """Utilities common to more than one resource.""" import uuid -from gn_auth.auth.db import sqlite3 as db +from gn_libs import sqlite3 as db def assign_resource_owner_role( cursor: db.DbCursor, diff --git a/gn_auth/auth/authorisation/resources/models.py b/gn_auth/auth/authorisation/resources/models.py index 27ef183..5762551 100644 --- a/gn_auth/auth/authorisation/resources/models.py +++ b/gn_auth/auth/authorisation/resources/models.py @@ -6,10 +6,12 @@ from uuid import UUID, uuid4 from functools import reduce, partial from typing import Dict, Union, Sequence, Optional +from flask import current_app as app + from gn_libs import sqlite3 as db +from gn_libs.sqlite3 import with_db_connection from gn_auth.auth.authentication.users import User -from gn_auth.auth.db.sqlite3 import with_db_connection from gn_auth.auth.authorisation.roles import Role from gn_auth.auth.authorisation.privileges import Privilege @@ -335,8 +337,9 @@ def link_data_to_resource( raise AuthorisationError( "You are not authorised to link/unlink data to this resource.") - resource = with_db_connection(partial( - resource_by_id, user=user, resource_id=resource_id)) + resource = with_db_connection( + app.config["AUTH_DB"], + partial(resource_by_id, user=user, resource_id=resource_id)) return {# type: ignore[operator] "mrna": mrna_link_data_to_resource, "genotype": genotype_link_data_to_resource, @@ -350,8 +353,9 @@ def unlink_data_from_resource( raise AuthorisationError( "You are not authorised to link/unlink data this resource.") - resource = with_db_connection(partial( - resource_by_id, user=user, resource_id=resource_id)) + resource = with_db_connection( + app.config["AUTH_DB"], + partial(resource_by_id, user=user, resource_id=resource_id)) dataset_type = resource.resource_category.resource_category_key return { "mrna": mrna_unlink_data_from_resource, |
