From 5680eb5fd1053f695e5917891f916ae85c212d3e Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 30 May 2024 12:31:47 -0500 Subject: Use asdict(...) Use dataclasses.asdict function to generate the dict that will be used for the response rather than building it up manually. --- gn_auth/auth/authorisation/users/views.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'gn_auth/auth/authorisation/users/views.py') diff --git a/gn_auth/auth/authorisation/users/views.py b/gn_auth/auth/authorisation/users/views.py index 9ea0c59..feacae3 100644 --- a/gn_auth/auth/authorisation/users/views.py +++ b/gn_auth/auth/authorisation/users/views.py @@ -105,12 +105,7 @@ def register_user() -> Response: cursor, save_user( cursor, email["email"], user_name), password) assign_default_roles(cursor, user) - return jsonify( - { - "user_id": user.user_id, - "email": user.email, - "name": user.name - }) + return jsonify(asdict(user)) except sqlite3.IntegrityError as sq3ie: current_app.logger.debug(traceback.format_exc()) raise UserRegistrationError( -- cgit v1.2.3