diff options
author | Frederick Muriuki Muriithi | 2024-05-30 11:58:20 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-06-03 10:02:07 -0500 |
commit | d2e9e9afde6d01bca49e5173282ac318c37460e0 (patch) | |
tree | 47ebcac8d23261c33eda3cd8c401defd628ff93c /gn_auth | |
parent | d0150a1cee14edce64481920af539b89d5bd3cc8 (diff) | |
download | gn-auth-d2e9e9afde6d01bca49e5173282ac318c37460e0.tar.gz |
Save the creation date and verification status.
Diffstat (limited to 'gn_auth')
-rw-r--r-- | gn_auth/auth/authentication/users.py | 21 |
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""" |