From 88070363558aa8c8f55021d8db1c410007d8854b Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 19 Jan 2023 11:51:52 +0300 Subject: auth: Fix user registration The code checking for errors was buggy and would let empty values through. The sqlite3.IntegrityError exception was not being handled correctly, and would cause a failure in the application. This commit fixes the issues noted above. * gn3/auth/authorisation/roles.py: fix bug in generating query params * gn3/auth/authorisation/views.py: fix error checking code. Raise exception if email is already registered. --- gn3/auth/authorisation/roles.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gn3/auth/authorisation/roles.py') diff --git a/gn3/auth/authorisation/roles.py b/gn3/auth/authorisation/roles.py index 606403e..9e2e83e 100644 --- a/gn3/auth/authorisation/roles.py +++ b/gn3/auth/authorisation/roles.py @@ -91,8 +91,8 @@ def assign_default_roles(cursor: db.DbCursor, user: User): '("group-creator")') role_ids = cursor.fetchall() str_user_id = str(user.user_id) - params = ( - {"user_id": str_user_id, "role_id": role_id} for role_id in role_ids) + params = tuple( + {"user_id": str_user_id, "role_id": row["role_id"]} for row in role_ids) cursor.executemany( ("INSERT INTO user_roles VALUES (:user_id, :role_id)"), params) -- cgit v1.2.3