diff options
author | Frederick Muriuki Muriithi | 2025-02-17 13:10:43 -0600 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-02-17 13:10:43 -0600 |
commit | 073395ff331042a5c686a46fa124f9cc6e10dd2f (patch) | |
tree | 41ccbc9f8efec299d95cd6332578e6e3228c97db /gn_auth/auth/authorisation/resources/inbredset | |
parent | 0ce16d56017e9144601116e62e3420ea17c89c25 (diff) | |
download | gn-auth-073395ff331042a5c686a46fa124f9cc6e10dd2f.tar.gz |
Use default sys-admin group if user is not a member of any group.
Instead of failing, assign any population resource to the default
system admin group, if the user is not a member of any group.
Diffstat (limited to 'gn_auth/auth/authorisation/resources/inbredset')
-rw-r--r-- | gn_auth/auth/authorisation/resources/inbredset/views.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/gn_auth/auth/authorisation/resources/inbredset/views.py b/gn_auth/auth/authorisation/resources/inbredset/views.py index b559105..40dd38d 100644 --- a/gn_auth/auth/authorisation/resources/inbredset/views.py +++ b/gn_auth/auth/authorisation/resources/inbredset/views.py @@ -7,7 +7,7 @@ from gn_auth.auth.db import sqlite3 as db from gn_auth.auth.requests import request_json from gn_auth.auth.db.sqlite3 import with_db_connection from gn_auth.auth.authentication.oauth2.resource_server import require_oauth -from gn_auth.auth.authorisation.resources.groups.models import user_group +from gn_auth.auth.authorisation.resources.groups.models import user_group, admin_group from .models import (create_resource, link_data_to_resource, @@ -83,7 +83,14 @@ def create_population_resource(): return Right({"formdata": form, "group": usergroup}) - return user_group(conn, _token.user).then( + def __default_group_if_none__(group) -> Either: + if group.is_nothing(): + return admin_group(conn) + return Right(group.value) + + return __default_group_if_none__( + user_group(conn, _token.user) + ).then( lambda group: __check_form__(request_json(), group) ).then( lambda formdata: { |