From fcbdfbd744c08272a8ea886bdd0f56d6887ef5dd Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 26 Feb 2025 23:35:09 -0800 Subject: [PATCH] refac --- backend/open_webui/utils/audit.py | 2 +- backend/open_webui/utils/auth.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/utils/audit.py b/backend/open_webui/utils/audit.py index 95c0745a9..2d7ceabcb 100644 --- a/backend/open_webui/utils/audit.py +++ b/backend/open_webui/utils/audit.py @@ -194,7 +194,7 @@ class AuditLoggingMiddleware: auth_header = request.headers.get("Authorization") assert auth_header - user = get_current_user(request, get_http_authorization_cred(auth_header)) + user = get_current_user(request, None, get_http_authorization_cred(auth_header)) return user diff --git a/backend/open_webui/utils/auth.py b/backend/open_webui/utils/auth.py index f4cf8543b..cbc8b15ae 100644 --- a/backend/open_webui/utils/auth.py +++ b/backend/open_webui/utils/auth.py @@ -205,7 +205,8 @@ def get_current_user( else: # Refresh the user's last active timestamp asynchronously # to prevent blocking the request - background_tasks.add_task(Users.update_user_last_active_by_id, user.id) + if background_tasks: + background_tasks.add_task(Users.update_user_last_active_by_id, user.id) return user else: raise HTTPException(