aboutsummaryrefslogtreecommitdiff
path: root/gn_auth
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-10-03 13:35:52 -0500
committerFrederick Muriuki Muriithi2024-10-03 13:35:52 -0500
commit00f863b3dcb76f5fdca8e139e903e2f7edb861fc (patch)
treed58ed5deca686a150b4dc88c66cf049ea66c00e2 /gn_auth
parent45f2eaa9d2965c79d77c898aab3a01a1f06e4149 (diff)
downloadgn-auth-00f863b3dcb76f5fdca8e139e903e2f7edb861fc.tar.gz
BugFix: Remove duplicates from resources list
Issue: https://issues.genenetwork.org/issues/gn-auth/resources-duplicates-in-resources-list The query was returning multiple instances of the same resource in situations where a user had more than one role of a particular resource.
Diffstat (limited to 'gn_auth')
-rw-r--r--gn_auth/auth/authorisation/resources/models.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/gn_auth/auth/authorisation/resources/models.py b/gn_auth/auth/authorisation/resources/models.py
index 8d3cfc3..c1748f1 100644
--- a/gn_auth/auth/authorisation/resources/models.py
+++ b/gn_auth/auth/authorisation/resources/models.py
@@ -133,8 +133,10 @@ def user_resources(conn: db.DbConnection, user: User) -> Sequence[Resource]:
"""List the resources available to the user"""
with db.cursor(conn) as cursor:
cursor.execute(
- ("SELECT r.*, rc.resource_category_key, "
- "rc.resource_category_description FROM user_roles AS ur "
+ ("SELECT DISTINCT(r.resource_id), r.resource_name, "
+ "r.resource_category_id, r.public, rc.resource_category_key, "
+ "rc.resource_category_description "
+ "FROM user_roles AS ur "
"INNER JOIN resources AS r ON ur.resource_id=r.resource_id "
"INNER JOIN resource_categories AS rc "
"ON r.resource_category_id=rc.resource_category_id "