fix: convert user creation and update dates to timezone-aware datetime

This commit is contained in:
Théophile Diot 2024-12-03 12:08:09 +01:00
parent a661d16c38
commit 2fdbff85a9
No known key found for this signature in database
GPG key ID: FA995104A0BA376A
2 changed files with 4 additions and 4 deletions

View file

@ -54,8 +54,8 @@ class UIDatabase(Database):
"method": ui_user.method,
"theme": ui_user.theme,
"totp_secret": ui_user.totp_secret,
"creation_date": ui_user.creation_date,
"update_date": ui_user.update_date,
"creation_date": ui_user.creation_date.astimezone(),
"update_date": ui_user.update_date.astimezone(),
"roles": [role.role_name for role in ui_user.roles],
"recovery_codes": [recovery_code.code for recovery_code in ui_user.recovery_codes],
}

View file

@ -248,8 +248,8 @@ def setup_loading():
db_config = DB.get_config(filtered_settings=("SERVER_NAME", "USE_UI", "REVERSE_PROXY_URL"))
ui_service = {}
ui_admin = DB.get_ui_user()
admin_old_enough = ui_admin and ui_admin.creation_date < datetime.now().astimezone() - timedelta(minutes=5)
ui_admin = DB.get_ui_user(as_dict=True)
admin_old_enough = ui_admin and ui_admin["creation_date"] < datetime.now().astimezone() - timedelta(minutes=5)
for server_name in db_config["SERVER_NAME"].split(" "):
if server_name and db_config.get(f"{server_name}_USE_UI", "no") == "yes":