Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
registration: Return status code 404 if invalid confirmation key passed.
Mateusz Manderad17a4f64d65f
diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.pyindex 9948da3a4ad..776f0deaf65 100644--- a/zerver/tests/test_signup.py+++ b/zerver/tests/test_signup.py@@ -1968,10 +1968,8 @@ so we didn't send them an invitation. We did send invitations to everyone else!"response = self.client_post(url, {"key": registration_key, "from_confirmation": 1, "full_nme": "alice"})- self.assertEqual(response.status_code, 200)- self.assert_in_success_response(- ["The registration link has expired or is not valid."], response- )+ self.assertEqual(response.status_code, 404)+ self.assert_in_response("The registration link has expired or is not valid.", response)registration_key = confirmation_link.split("/")[-1]response = self.client_post(@@ -3567,10 +3565,8 @@ class UserSignUpTest(InviteUserBase):},)# Error page should be displayed- self.assert_in_success_response(- ["The registration link has expired or is not valid."], result- )- self.assertEqual(result.status_code, 200)+ self.assertEqual(result.status_code, 404)+ self.assert_in_response("The registration link has expired or is not valid.", result)def test_signup_with_multiple_default_stream_groups(self) -> None:# Check if user is subscribed to the streams of defaultdiff --git a/zerver/views/registration.py b/zerver/views/registration.pyindex d68f2e3dd50..c86929e76fb 100644--- a/zerver/views/registration.py+++ b/zerver/views/registration.py@@ -123,11 +123,11 @@ def accounts_register(request: HttpRequest) -> HttpResponse:key = request.POST.get("key", default="")confirmation = Confirmation.objects.get(confirmation_key=key)except Confirmation.DoesNotExist:- return render(request, "zerver/confirmation_link_expired_error.html")+ return render(request, "zerver/confirmation_link_expired_error.html", status=404)prereg_user = confirmation.content_objectif prereg_user.status == confirmation_settings.STATUS_REVOKED:- return render(request, "zerver/confirmation_link_expired_error.html")+ return render(request, "zerver/confirmation_link_expired_error.html", status=404)email = prereg_user.emailrealm_creation = prereg_user.realm_creationpassword_required = prereg_user.password_required