diff options
Diffstat (limited to 'gn_auth/auth/authorisation/roles/views.py')
| -rw-r--r-- | gn_auth/auth/authorisation/roles/views.py | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/gn_auth/auth/authorisation/roles/views.py b/gn_auth/auth/authorisation/roles/views.py index 00def89..91292e7 100644 --- a/gn_auth/auth/authorisation/roles/views.py +++ b/gn_auth/auth/authorisation/roles/views.py @@ -7,7 +7,7 @@ from flask import jsonify, Response, Blueprint, current_app from ...db import sqlite3 as db -from .models import user_role +from .models import role_by_id from ...authentication.oauth2.resource_server import require_oauth @@ -17,11 +17,7 @@ roles = Blueprint("roles", __name__) @require_oauth("profile role") def view_role(role_id: uuid.UUID) -> Response: """Retrieve a user role with id `role_id`""" - def __error__(exc: Exception): - raise exc - with require_oauth.acquire("profile role") as the_token: + with require_oauth.acquire("profile role") as _token: db_uri = current_app.config["AUTH_DB"] with db.connection(db_uri) as conn: - the_role = user_role(conn, the_token.user, role_id) - return the_role.either( - __error__, lambda a_role: jsonify((asdict(a_role[0]), str(a_role[1])))) + return jsonify(asdict(role_by_id(conn, role_id)))# type: ignore[arg-type] |
