]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Chore: add some output of social login errors (#11527)
authorshamoon <4887959+shamoon@users.noreply.github.com>
Wed, 3 Dec 2025 18:52:49 +0000 (10:52 -0800)
committerGitHub <noreply@github.com>
Wed, 3 Dec 2025 18:52:49 +0000 (18:52 +0000)
src/paperless/adapter.py
src/paperless/tests/test_adapter.py

index f8517a3aa1ba444494ad24ff4541484df638e677..a4506275e10cc9db23c82c732559d18ea291dda2 100644 (file)
@@ -137,3 +137,25 @@ class CustomSocialAccountAdapter(DefaultSocialAccountAdapter):
             user.save()
         handle_social_account_updated(None, request, sociallogin)
         return user
+
+    def on_authentication_error(
+        self,
+        request,
+        provider,
+        error=None,
+        exception=None,
+        extra_context=None,
+    ):
+        """
+        Just log errors and pass them along.
+        """
+        logger.warning(
+            f"Social authentication error for provider `{provider!s}`: {error!s} ({exception!s})",
+        )
+        return super().on_authentication_error(
+            request,
+            provider,
+            error,
+            exception,
+            extra_context,
+        )
index bbd7ff73e5f38b409e969f620e6fbfff81e73d54..37b8aaa3bc71679a14f09cbb4d64424827c45ff4 100644 (file)
@@ -167,3 +167,17 @@ class TestCustomSocialAccountAdapter(TestCase):
         self.assertEqual(user.groups.count(), 1)
         self.assertTrue(user.groups.filter(name="group1").exists())
         self.assertFalse(user.groups.filter(name="group2").exists())
+
+    def test_error_logged_on_authentication_error(self):
+        adapter = get_social_adapter()
+        request = HttpRequest()
+        with self.assertLogs("paperless.auth", level="INFO") as log_cm:
+            adapter.on_authentication_error(
+                request,
+                provider="test-provider",
+                error="Error",
+                exception="Test authentication error",
+            )
+        self.assertTrue(
+            any("Test authentication error" in message for message in log_cm.output),
+        )