A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
fix broken "failed login" signal
Igor Rzegocki4a02865697d3
diff --git a/src/paperless/auth.py b/src/paperless/auth.pyindex ec853743e..2285d0526 100644--- a/src/paperless/auth.py+++ b/src/paperless/auth.py@@ -1,6 +1,6 @@from django.conf import settingsfrom django.contrib import auth-from django.contrib.auth.middleware import RemoteUserMiddleware+from django.contrib.auth.middleware import PersistentRemoteUserMiddlewarefrom django.contrib.auth.models import Userfrom django.utils.deprecation import MiddlewareMixinfrom rest_framework import authentication@@ -37,7 +37,7 @@ class AngularApiAuthenticationOverride(authentication.BaseAuthentication):return None-class HttpRemoteUserMiddleware(RemoteUserMiddleware):+class HttpRemoteUserMiddleware(PersistentRemoteUserMiddleware):"""This class allows authentication via HTTP_REMOTE_USER which is set forexample by certain SSO applications."""diff --git a/src/paperless/signals.py b/src/paperless/signals.pyindex 83ba74193..9dc3383e3 100644--- a/src/paperless/signals.py+++ b/src/paperless/signals.py@@ -12,22 +12,21 @@ def handle_failed_login(sender, credentials, request, **kwargs):client_ip, _ = ipware.get_client_ip(meta=request.META,)+ username = credentials.get("username") or "anonymous"if client_ip is None:logger.info(- f"Login failed for user `{credentials['username']}`."- " Unable to determine IP address.",+ f"Login failed for user `{username}`. Unable to determine IP address.",)else:if client_ip.is_global:# We got the client's IP addresslogger.info(- f"Login failed for user `{credentials['username']}`"- f" from IP `{client_ip}.`",+ f"Login failed for user `{username}` from IP `{client_ip}.`",)else:# The client's IP address is privatelogger.info(- f"Login failed for user `{credentials['username']}`"+ f"Login failed for user `{username}`"f" from private IP `{client_ip}.`",)