Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
emails: Extend expiration for login confirmation links.
Tim Abbottf1ffb1f56e67
diff --git a/corporate/tests/test_remote_billing.py b/corporate/tests/test_remote_billing.pyindex 2b1bb16db91..9e6010afa4a 100644--- a/corporate/tests/test_remote_billing.py+++ b/corporate/tests/test_remote_billing.py@@ -88,7 +88,7 @@ class RemoteBillingAuthenticationTest(BouncerTestCase):f"{settings.SELF_HOSTING_MANAGEMENT_SUBDOMAIN}.{settings.EXTERNAL_HOST}"r"(\S+)"),- email_body_contains="This link will expire in 2 hours",+ email_body_contains="This link will expire in 24 hours",)if return_without_clicking_confirmation_link:return result@@ -514,7 +514,7 @@ class LegacyServerLoginTest(BouncerTestCase):url_pattern=(f"{settings.SELF_HOSTING_MANAGEMENT_SUBDOMAIN}.{settings.EXTERNAL_HOST}" + r"(\S+)"),- email_body_contains="This link will expire in 2 hours",+ email_body_contains="This link will expire in 24 hours",)if return_without_clicking_confirmation_link:return resultdiff --git a/corporate/views/remote_billing_page.py b/corporate/views/remote_billing_page.pyindex 705e9f148ff..4a78cd90e28 100644--- a/corporate/views/remote_billing_page.py+++ b/corporate/views/remote_billing_page.py@@ -58,6 +58,9 @@ VALID_NEXT_PAGES = [None, "sponsorship", "upgrade", "billing", "plans"]VALID_NEXT_PAGES_TYPE = Literal[None, "sponsorship", "upgrade", "billing", "plans"]REMOTE_BILLING_SIGNED_ACCESS_TOKEN_VALIDITY_IN_SECONDS = 2 * 60 * 60+# We use units of hours here so that we can pass this through to the+# email template that tells the recipient how long these will last.+LOGIN_CONFIRMATION_EMAIL_DURATION_HOURS = 24@csrf_exempt@@ -308,9 +311,7 @@ def remote_realm_billing_confirm_email(url = create_remote_billing_confirmation_link(obj,Confirmation.REMOTE_REALM_BILLING_LEGACY_LOGIN,- # Use the same expiration time as for the signed access token,- # since this is similarly transient in nature.- validity_in_minutes=int(REMOTE_BILLING_SIGNED_ACCESS_TOKEN_VALIDITY_IN_SECONDS / 60),+ validity_in_minutes=LOGIN_CONFIRMATION_EMAIL_DURATION_HOURS * 60,)context = {@@ -318,6 +319,7 @@ def remote_realm_billing_confirm_email("confirmation_url": url,"billing_help_link": "https://zulip.com/help/self-hosted-billing","billing_contact_email": "[email protected]",+ "validity_in_hours": LOGIN_CONFIRMATION_EMAIL_DURATION_HOURS,}send_email("zerver/emails/remote_realm_billing_confirm_login",@@ -522,9 +524,7 @@ def remote_billing_legacy_server_confirm_login(url = create_remote_billing_confirmation_link(obj,Confirmation.REMOTE_SERVER_BILLING_LEGACY_LOGIN,- # Use the same expiration time as for the signed access token,- # since this is similarly transient in nature.- validity_in_minutes=int(REMOTE_BILLING_SIGNED_ACCESS_TOKEN_VALIDITY_IN_SECONDS / 60),+ validity_in_minutes=LOGIN_CONFIRMATION_EMAIL_DURATION_HOURS * 60,)context = {@@ -532,6 +532,7 @@ def remote_billing_legacy_server_confirm_login("confirmation_url": url,"billing_help_link": "https://zulip.com/help/self-hosted-billing","billing_contact_email": "[email protected]",+ "validity_in_hours": LOGIN_CONFIRMATION_EMAIL_DURATION_HOURS,}send_email("zerver/emails/remote_billing_legacy_server_confirm_login",diff --git a/templates/zerver/emails/remote_billing_legacy_server_confirm_login.html b/templates/zerver/emails/remote_billing_legacy_server_confirm_login.htmlindex 003728a4b5c..85edd743bca 100644--- a/templates/zerver/emails/remote_billing_legacy_server_confirm_login.html+++ b/templates/zerver/emails/remote_billing_legacy_server_confirm_login.html@@ -9,7 +9,13 @@{% trans %}Either you, or someone on your behalf, has requested a log in link to manage the Zulip plan for <b>{{ remote_server_hostname }}</b>.{% endtrans %}</p><p>- {{ _("Click the button below to log in. This link will expire in 2 hours.") }}+ {% trans %}+ Click the button below to log in.+ {% endtrans %}++ {% trans %}+ This link will expire in {{ validity_in_hours }} hours.+ {% endtrans %}</p><p><a class="button" href="{{ confirmation_url }}">{{ _("Log in") }}</a>diff --git a/templates/zerver/emails/remote_billing_legacy_server_confirm_login.txt b/templates/zerver/emails/remote_billing_legacy_server_confirm_login.txtindex f5ec54546f5..4b6a5709de3 100644--- a/templates/zerver/emails/remote_billing_legacy_server_confirm_login.txt+++ b/templates/zerver/emails/remote_billing_legacy_server_confirm_login.txt@@ -1,7 +1,7 @@{% trans %}Either you, or someone on your behalf, has requested a log in link to manage the Zulip plan for {{ remote_server_hostname }}.{% endtrans %}-{{ _("Click the link below to log in. This link will expire in 2 hours.") }}+{% trans %}Click the link below to log in.{% endtrans %} {% trans %}This link will expire in {{ validity_in_hours }} hours.{% endtrans %}{{ _("Log in") }}: {{ confirmation_url }}diff --git a/templates/zerver/emails/remote_realm_billing_confirm_login.html b/templates/zerver/emails/remote_realm_billing_confirm_login.htmlindex 697fdc1020d..55b1cdcfdcf 100644--- a/templates/zerver/emails/remote_realm_billing_confirm_login.html+++ b/templates/zerver/emails/remote_realm_billing_confirm_login.html@@ -6,7 +6,13 @@{% block content %}<p>- {% trans %}Click the button below to log in to Zulip plan management for <b>{{ remote_realm_host }}</b>. This link will expire in 2 hours.{% endtrans %}+ {% trans %}+ Click the button below to log in to Zulip plan management for <b>{{ remote_realm_host }}</b>.+ {% endtrans %}++ {% trans %}+ This link will expire in {{ validity_in_hours }} hours.+ {% endtrans %}</p><p><a class="button" href="{{ confirmation_url }}">{{ _("Log in") }}</a>diff --git a/templates/zerver/emails/remote_realm_billing_confirm_login.txt b/templates/zerver/emails/remote_realm_billing_confirm_login.txtindex dc1a6761c3d..658472e590e 100644--- a/templates/zerver/emails/remote_realm_billing_confirm_login.txt+++ b/templates/zerver/emails/remote_realm_billing_confirm_login.txt@@ -1,4 +1,4 @@-{% trans %}Click the link below to log in to Zulip plan management for {{ remote_realm_host }}. This link will expire in 2 hours.{% endtrans %}+{% trans %}Click the link below to log in to Zulip plan management for {{remote_realm_host}}.{% endtrans %} {% trans %}This link will expire in {{ validity_in_hours }} hours.{% endtrans %}{{ _("Log in") }}: {{ confirmation_url }}