about summary refs log tree commit diff
path: root/gn_auth
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-05-30 11:58:20 -0500
committerFrederick Muriuki Muriithi2024-06-03 10:02:07 -0500
commitd2e9e9afde6d01bca49e5173282ac318c37460e0 (patch)
tree47ebcac8d23261c33eda3cd8c401defd628ff93c /gn_auth
parentd0150a1cee14edce64481920af539b89d5bd3cc8 (diff)
downloadgn-auth-d2e9e9afde6d01bca49e5173282ac318c37460e0.tar.gz
Save the creation date and verification status.
Diffstat (limited to 'gn_auth')
-rw-r--r--gn_auth/auth/authentication/users.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/gn_auth/auth/authentication/users.py b/gn_auth/auth/authentication/users.py
index ca37524..c2c1162 100644
--- a/gn_auth/auth/authentication/users.py
+++ b/gn_auth/auth/authentication/users.py
@@ -70,7 +70,13 @@ def valid_login(conn: db.DbConnection, user: User, password: str) -> bool:
 
     return same_password(password, row["password"])
 
-def save_user(cursor: db.DbCursor, email: str, name: str) -> User:
+def save_user(
+        cursor: db.DbCursor,
+        email: str,
+        name: str,
+        created: datetime.datetime = datetime.datetime.now(),
+        verified: bool = False
+) -> User:
     """
     Create and persist a user.
 
@@ -80,9 +86,16 @@ def save_user(cursor: db.DbCursor, email: str, name: str) -> User:
     The newly created and persisted user is then returned.
     """
     user_id = uuid4()
-    cursor.execute("INSERT INTO users VALUES (?, ?, ?)",
-                   (str(user_id), email, name))
-    return User(user_id, email, name)
+    cursor.execute(
+        ("INSERT INTO users(user_id, email, name, created, verified) "
+         "VALUES (?, ?, ?, ?, ?)"),
+        (
+            str(user_id),
+            email,
+            name,
+            int(created.timestamp()),
+            (1 if verified else 0)))
+    return User(user_id, email, name, created, verified)
 
 def hasher():
     """Retrieve PasswordHasher object"""