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/groups.py | |
parent | c7f3860a33b9adf327bb1f0f8ad15b3c0753ab55 (diff) | |
download | genenetwork3-920648f55475ad706828f696141dcd07edb1ef73.tar.gz |
auth: API: retrieve resources
Diffstat (limited to 'gn3/auth/authorisation/groups.py')
-rw-r--r-- | gn3/auth/authorisation/groups.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/gn3/auth/authorisation/groups.py b/gn3/auth/authorisation/groups.py index cd7e034..201ed4d 100644 --- a/gn3/auth/authorisation/groups.py +++ b/gn3/auth/authorisation/groups.py @@ -163,7 +163,13 @@ def user_group(cursor: db.DbCursor, user: User) -> Either: def is_group_leader(cursor: db.DbCursor, user: User, group: Group): """Check whether the given `user` is the leader of `group`.""" - ugroup = user_group(cursor, user).maybe(False, lambda val: val) # type: ignore[arg-type, misc] + def __raise__(exc): + if type(exc) == NotFoundError: + return False + raise exc + + ugroup = user_group(cursor, user).either( + __raise__, lambda val: val) # type: ignore[arg-type, misc] if not group: # User cannot be a group leader if not a member of ANY group return False |