Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
remote_billing: Redirect via next_page param in legacy server flow.
Mateusz Mandera44ac99b8fc0c
diff --git a/corporate/views/remote_billing_page.py b/corporate/views/remote_billing_page.pyindex da590924689..17ca4b988e5 100644--- a/corporate/views/remote_billing_page.py+++ b/corporate/views/remote_billing_page.py@@ -1,5 +1,5 @@import logging-from typing import Literal, Optional+from typing import Any, Dict, Literal, Optionalfrom django.conf import settingsfrom django.core import signing@@ -233,44 +233,31 @@ def remote_billing_legacy_server_login(*,server_org_id: Optional[str] = None,server_org_secret: Optional[str] = None,+ next_page: VALID_NEXT_PAGES_TYPE = None,) -> HttpResponse:+ context: Dict[str, Any] = {"next_page": next_page}if server_org_id is None or server_org_secret is None:- # Should not be possible to submit the form like this, so this is the default- # case, where the user just opened this page and therefore we render a fresh form.- return render(- request,- "corporate/legacy_server_login.html",- context={"error_message": False},- )+ context.update({"error_message": False})+ return render(request, "corporate/legacy_server_login.html", context)- # The form must be submitted via POST.if request.method != "POST":return HttpResponseNotAllowed(["POST"])try:remote_server = get_remote_server_by_uuid(server_org_id)except RemoteZulipServer.DoesNotExist:- return render(- request,- "corporate/legacy_server_login.html",- context={- "error_message": _("Did not find a server registration for this server_org_id.")- },+ context.update(+ {"error_message": _("Did not find a server registration for this server_org_id.")})+ return render(request, "corporate/legacy_server_login.html", context)if not constant_time_compare(server_org_secret, remote_server.api_key):- return render(- request,- "corporate/legacy_server_login.html",- context={"error_message": _("Invalid server_org_secret.")},- )- if remote_server.deactivated:- return render(- request,- "corporate/legacy_server_login.html",- context={"error_message": _("Your server registration has been deactivated.")},- )+ context.update({"error_message": _("Invalid server_org_secret.")})+ return render(request, "corporate/legacy_server_login.html", context)+ if remote_server.deactivated:+ context.update({"error_message": _("Your server registration has been deactivated.")})+ return render(request, "corporate/legacy_server_login.html", context)remote_server_uuid = str(remote_server.uuid)request.session["remote_billing_identities"] = {}@@ -281,4 +268,12 @@ def remote_billing_legacy_server_login(authenticated_at=datetime_to_timestamp(timezone_now()),)- return HttpResponseRedirect(reverse("remote_server_billing_page", args=(remote_server_uuid,)))+ assert next_page in VALID_NEXT_PAGES+ if next_page is None:+ return HttpResponseRedirect(+ reverse("remote_server_billing_page", args=(remote_server_uuid,))+ )+ else:+ return HttpResponseRedirect(+ reverse(f"remote_server_{next_page}_page", args=(remote_server_uuid,))+ )diff --git a/templates/corporate/legacy_server_login.html b/templates/corporate/legacy_server_login.htmlindex 36f1eede2b9..28cebc9ca71 100644--- a/templates/corporate/legacy_server_login.html+++ b/templates/corporate/legacy_server_login.html@@ -17,6 +17,9 @@<div id="server-login-input-section"><form id="server-login-form" method="post" action="/serverlogin/">{{ csrf_input }}+ {% if next_page %}+ <input type="hidden" name="next_page" value="{{ next_page }}" />+ {% endif %}<div class="input-box server-login-form-field"><label for="username" class="inline-block label-title">server_org_id