diff options
author | Frederick Muriuki Muriithi | 2023-01-30 03:23:19 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-01-30 03:23:19 +0300 |
commit | 920648f55475ad706828f696141dcd07edb1ef73 (patch) | |
tree | 5ba859f47c164cec3e78f286b33168bdb673870c /gn3/auth/authorisation/resources.py | |
parent | c7f3860a33b9adf327bb1f0f8ad15b3c0753ab55 (diff) | |
download | genenetwork3-920648f55475ad706828f696141dcd07edb1ef73.tar.gz |
auth: API: retrieve resources
Diffstat (limited to 'gn3/auth/authorisation/resources.py')
-rw-r--r-- | gn3/auth/authorisation/resources.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gn3/auth/authorisation/resources.py b/gn3/auth/authorisation/resources.py index 1e37d7a..c9cd392 100644 --- a/gn3/auth/authorisation/resources.py +++ b/gn3/auth/authorisation/resources.py @@ -136,6 +136,10 @@ def user_resources(conn: db.DbConnection, user: User) -> Sequence[Resource]: (private_res + gl_resources + public_resources(conn))# type: ignore[operator] }.values()) + def __handle_error__(exc): + if type(exc) == NotFoundError: + return public_resources(conn) + raise exc # Fix the typing here - return user_group(cursor, user).map(__all_resources__).maybe(# type: ignore[arg-type,misc] - public_resources(conn), lambda res: res)# type: ignore[arg-type,return-value] + return user_group(cursor, user).map(__all_resources__).either(# type: ignore[arg-type,misc] + __handle_error__, lambda res: res)# type: ignore[arg-type,return-value] |