aboutsummaryrefslogtreecommitdiff
path: root/gn3/auth/authorisation/roles.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-01-30 03:00:27 +0300
committerFrederick Muriuki Muriithi2023-01-30 03:00:27 +0300
commit5d21e8195d1a51a633608b20baa8dbee01d51a7c (patch)
treeec6ef38ff3b0615827ec7d9b5b8287b4925bd629 /gn3/auth/authorisation/roles.py
parent786c6f61c0dc635f908175a369fdd3e89ba7d7b2 (diff)
downloadgenenetwork3-5d21e8195d1a51a633608b20baa8dbee01d51a7c.tar.gz
auth: API: Retrieve a user's group
Add endpoint to retrieve the group in which the user is a member.
Diffstat (limited to 'gn3/auth/authorisation/roles.py')
-rw-r--r--gn3/auth/authorisation/roles.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/gn3/auth/authorisation/roles.py b/gn3/auth/authorisation/roles.py
index e75163d..23b74cc 100644
--- a/gn3/auth/authorisation/roles.py
+++ b/gn3/auth/authorisation/roles.py
@@ -13,7 +13,7 @@ from gn3.auth.authentication.checks import authenticated_p
from .checks import authorised_p
from .privileges import Privilege
-from .errors import AuthorisationError
+from .errors import NotFoundError, AuthorisationError
class Role(NamedTuple):
"""Class representing a role: creates immutable objects."""
@@ -28,10 +28,6 @@ class Role(NamedTuple):
"privileges": tuple(dictify(priv) for priv in self.privileges)
}
-class RoleNotFoundError(AuthorisationError):
- """Raised whenever we try fetching (a) role(s) that do(es) not exist."""
- error_code: int = 404
-
@authenticated_p
@authorised_p(("group:role:create-role",), error_message="Could not create role")
def create_role(
@@ -115,7 +111,7 @@ def user_role(conn: db.DbConnection, user: User, role_id: UUID) -> Either:
if results:
return Right(tuple(
reduce(__organise_privileges__, results, {}).values())[0])
- return Left(RoleNotFoundError(
+ return Left(NotFoundError(
f"Could not find role with id '{role_id}'",))
def assign_default_roles(cursor: db.DbCursor, user: User):