Jon Solow
commited on
Commit
·
d0acf6f
1
Parent(s):
ca6f10b
Return empty dict if no user in table and use get accessor
Browse files- src/data_storage.py +2 -0
- src/login.py +2 -2
src/data_storage.py
CHANGED
@@ -51,6 +51,8 @@ def get_user(user_id: int):
|
|
51 |
with get_db_connection() as con:
|
52 |
cur = con.cursor()
|
53 |
user_data = cur.execute(f"select * from users where user_id = {user_id}").fetchone()
|
|
|
|
|
54 |
return {
|
55 |
"user_id": user_data[0],
|
56 |
"email": user_data[1],
|
|
|
51 |
with get_db_connection() as con:
|
52 |
cur = con.cursor()
|
53 |
user_data = cur.execute(f"select * from users where user_id = {user_id}").fetchone()
|
54 |
+
if not user_data:
|
55 |
+
return {}
|
56 |
return {
|
57 |
"user_id": user_data[0],
|
58 |
"email": user_data[1],
|
src/login.py
CHANGED
@@ -159,6 +159,6 @@ def get_logged_in_user_name_email() -> tuple[str | None, str | None]:
|
|
159 |
return (None, None)
|
160 |
|
161 |
user_info_map = get_user(user_id)
|
162 |
-
email = user_info_map
|
163 |
-
name = user_info_map
|
164 |
return email, name
|
|
|
159 |
return (None, None)
|
160 |
|
161 |
user_info_map = get_user(user_id)
|
162 |
+
email = user_info_map.get("email")
|
163 |
+
name = user_info_map.get("name")
|
164 |
return email, name
|