aboutsummaryrefslogtreecommitdiff
path: root/gn_auth
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-08-15 10:42:12 -0500
committerFrederick Muriuki Muriithi2024-08-15 10:42:12 -0500
commit51029b7bbac7d76a35bfe2f680e887c60aee6156 (patch)
tree73fefb10a0a03b453a142481c50d60aed2f64b27 /gn_auth
parent03c98f69e3c2069cde81a995f7591a35b7eda01c (diff)
downloadgn-auth-51029b7bbac7d76a35bfe2f680e887c60aee6156.tar.gz
Import specific classes from the datetime module.
Diffstat (limited to 'gn_auth')
-rw-r--r--gn_auth/auth/authorisation/users/views.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/gn_auth/auth/authorisation/users/views.py b/gn_auth/auth/authorisation/users/views.py
index 363da92..0922e1e 100644
--- a/gn_auth/auth/authorisation/users/views.py
+++ b/gn_auth/auth/authorisation/users/views.py
@@ -1,12 +1,12 @@
"""User authorisation endpoints."""
import sqlite3
import secrets
-import datetime
import traceback
from typing import Any
from functools import partial
from dataclasses import asdict
from urllib.parse import urljoin
+from datetime import datetime, timedelta
from email.headerregistry import Address
from email_validator import validate_email, EmailNotValidError
from flask import (
@@ -123,7 +123,7 @@ def send_verification_email(
"""Send an email verification message."""
subject="GeneNetwork: Please Verify Your Email"
verification_code = secrets.token_urlsafe(64)
- generated = datetime.datetime.now()
+ generated = datetime.now()
expiration_minutes = 15
def __render__(template):
return render_template(template,
@@ -148,7 +148,7 @@ def send_verification_email(
"generated": int(generated.timestamp()),
"expires": int(
(generated +
- datetime.timedelta(
+ timedelta(
minutes=expiration_minutes)).timestamp())
})
send_message(smtp_user=current_app.config["SMTP_USER"],
@@ -236,8 +236,8 @@ def verify_user():
return loginuri
results = results[0]
- if (datetime.datetime.fromtimestamp(
- int(results["expires"])) < datetime.datetime.now()):
+ if (datetime.fromtimestamp(
+ int(results["expires"])) < datetime.now()):
delete_verification_code(cursor, verificationcode)
flash("Invalid verification code: code has expired.",
"alert-danger")