From 27d40788e2e2c8fbeb8873e895d77a76bbd49a45 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Mon, 11 Mar 2024 19:34:18 +0300 Subject: Define User using a frozen dataclass. * gn_auth/auth/authentication/users.py: Import dataclass. Remove NamedTuple and Tuple import. (User): Use a frozen dataclass. (User.get_user_id): Delete. (User.dictify): Ditto. * gn_auth/auth/authorisation/data/views.py: Import dataclasses.dict. (authorisation): Replace user._asdict() with asdict(user). (metadata_resources): Ditto. * gn_auth/auth/authorisation/resources/groups/views.py: (group_members): Replace dictify with asdict. * gn_auth/auth/authorisation/resources/models.py: Import dataclasses.asdict. (assign_resource_user): Replace dictify(user) with asdict(user). (unassign_resource_user): Ditto. * gn_auth/auth/authorisation/resources/views.py: (resource_users): Replace dictify with asdict. * gn_auth/auth/authorisation/users/masquerade/views.py: Import dataclasses.asdict. (masquerade): Replace masq_user._asdict() with asdict(masq_user). * gn_auth/auth/authorisation/users/views.py: (list_all_users): Replace dictify with asdict. Signed-off-by: Munyoki Kilyungi --- gn_auth/auth/authorisation/users/masquerade/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gn_auth/auth/authorisation/users/masquerade') diff --git a/gn_auth/auth/authorisation/users/masquerade/views.py b/gn_auth/auth/authorisation/users/masquerade/views.py index 259cdfe..b0464ba 100644 --- a/gn_auth/auth/authorisation/users/masquerade/views.py +++ b/gn_auth/auth/authorisation/users/masquerade/views.py @@ -1,4 +1,5 @@ """Endpoints for user masquerade""" +from dataclasses import asdict from uuid import UUID from functools import partial @@ -42,7 +43,7 @@ def masquerade() -> Response: "token": __dump_token__(token) }, "masquerade_as": { - "user": masq_user._asdict(), + "user": asdict(masq_user), "token": __dump_token__(with_db_connection(__masq__)) } }) -- cgit v1.2.3