housekeep: centralize datetime generation

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2022-01-18 05:59:52 -08:00
parent 7bcc8d7ce7
commit 7f6c23d4cb
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
41 changed files with 146 additions and 179 deletions

View file

@ -1,6 +1,5 @@
import functools
from datetime import datetime
from http import HTTPStatus
from typing import Callable
@ -13,7 +12,7 @@ from starlette.requests import HTTPConnection
import aurweb.config
from aurweb import db, filters, l10n, util
from aurweb import db, filters, l10n, time, util
from aurweb.models import Session, User
from aurweb.models.account_type import ACCOUNT_TYPE_ID
@ -110,7 +109,7 @@ class BasicAuthBackend(AuthenticationBackend):
"persistent_cookie_timeout")
# If no session with sid and a LastUpdateTS now or later exists.
now_ts = int(datetime.utcnow().timestamp())
now_ts = time.utcnow()
record = db.query(Session).filter(Session.SessionID == sid).first()
if not record:
return unauthenticated