From 920648f55475ad706828f696141dcd07edb1ef73 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 30 Jan 2023 03:23:19 +0300 Subject: auth: API: retrieve resources --- gn3/auth/authorisation/resources.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gn3/auth/authorisation/resources.py') 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] -- cgit v1.2.3