Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
auth: Improve Confirmation link error handling in social auth codepath.
Mateusz Mandera4a030f616fcd
diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.pyindex 7370ca9c5f7..9adc7fc979e 100644--- a/zerver/tests/test_auth_backends.py+++ b/zerver/tests/test_auth_backends.py@@ -1526,7 +1526,7 @@ class SocialAuthBase(DesktopFlowTestingLib, ZulipTestCase):result = self.client_get(result.url)self.assertEqual(result.status_code, 404)- self.assert_in_response("The registration link has expired or is not valid.", result)+ self.assert_in_response("Whoops. The confirmation link is malformed.", result)@override_settings(TERMS_OF_SERVICE=None)def test_social_auth_registration_using_multiuse_invite(self) -> None:diff --git a/zerver/views/auth.py b/zerver/views/auth.pyindex aed7d0d8a20..f185348d3c0 100644--- a/zerver/views/auth.py+++ b/zerver/views/auth.py@@ -34,6 +34,7 @@ from confirmation.models import (ConfirmationKeyException,create_confirmation_link,get_object_from_key,+ render_confirmation_key_error,)from version import API_FEATURE_LEVEL, ZULIP_MERGE_BASE, ZULIP_VERSIONfrom zerver.context_processors import get_realm_from_request, login_context, zulip_default_context@@ -187,8 +188,8 @@ def maybe_send_to_registration(from_multiuse_invite = Truetry:multiuse_obj = get_object_from_key(multiuse_object_key, [Confirmation.MULTIUSE_INVITE])- except ConfirmationKeyException:- return render(request, "zerver/confirmation_link_expired_error.html", status=404)+ except ConfirmationKeyException as exception:+ return render_confirmation_key_error(request, exception)assert multiuse_obj is not Nonerealm = multiuse_obj.realm