mirror of https://github.com/zulip/zulip.git
find-account: Send email when no Zulip accounts found.
Previously, email addresses that weren't connected to a Zulip account were ignored but now they receive an email stating their email isn't connected to a Zulip account. Also, removes the "Thanks for using Zulip!" line at the end of the find accounts email that's sent when a Zulip account is found. Updates the i18n test that used this string with another in the German translation from this a successful account found email. Fixes part of #3128 Co-authored-by: Lauryn Menard <lauryn@zulip.com>
This commit is contained in:
parent
968059c7ef
commit
5410df2a7b
|
@ -5,6 +5,7 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if account_found %}
|
||||
<p>{{ _("Thanks for your request!") }}</p>
|
||||
|
||||
{% if corporate_enabled %}
|
||||
|
@ -22,6 +23,19 @@
|
|||
<p>
|
||||
{% trans %}If you have trouble logging in, you can <a href="{{ help_reset_password_link }}">reset your password</a>.{% endtrans %}
|
||||
</p>
|
||||
{% else %}
|
||||
<p>
|
||||
{{ _("You have requested a list of Zulip accounts for this email address.") }}
|
||||
{% if corporate_enabled %}
|
||||
{{ _("Unfortunately, no Zulip Cloud accounts were found.") }}
|
||||
{% else %}
|
||||
{% trans%}Unfortunately, no accounts were found in Zulip organizations hosted by {{external_host}}.{% endtrans %}
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
<p>{{ _("Thanks for using Zulip!") }}</p>
|
||||
<p>
|
||||
{% trans %}You can <a href = "{{ find_accounts_link }}" >check for accounts</a> with another email, or <a href ="{{ help_logging_in_link }}">try another way</a> to find your account.{% endtrans %}
|
||||
{{ _("If you do not recognize this request, you can safely ignore this email.") }}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
{{ _("Your Zulip accounts") }}
|
||||
{% if account_found %}
|
||||
{{ _("Your Zulip accounts") }}
|
||||
{% else %}
|
||||
{{ _("No Zulip accounts found") }}
|
||||
{% endif %}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{% if account_found %}
|
||||
{{ _("Thanks for your request!") }}
|
||||
|
||||
{% if corporate_enabled %}
|
||||
|
@ -15,4 +16,21 @@
|
|||
|
||||
{{ help_reset_password_link }}
|
||||
|
||||
{{ _("Thanks for using Zulip!") }}
|
||||
{% else %}
|
||||
{% if corporate_enabled %}
|
||||
{{ _("You have requested a list of Zulip accounts for this email address.") }} {{ _("Unfortunately, no accounts in Zulip Cloud organizations were found.") }}
|
||||
|
||||
{% trans %}You can check for accounts with another email ({{ find_accounts_link }}), or try another way to find your account ({{ help_logging_in_link }}).{% endtrans %}
|
||||
|
||||
|
||||
{{ _("If you do not recognize this request, you can safely ignore this email.") }}
|
||||
{% else %}
|
||||
{{ _("You have requested a list of Zulip accounts for this email address.") }} {% trans%}Unfortunately, no accounts were found in Zulip organizations hosted by {{external_host}}.{% endtrans %}
|
||||
|
||||
|
||||
{% trans %}You can check for accounts with another email ({{ find_accounts_link }}), or try another way to find your account ({{ help_logging_in_link }}).{% endtrans %}
|
||||
|
||||
|
||||
{{ _("If you do not recognize this request, you can safely ignore this email.") }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
<div id="results">
|
||||
<p>
|
||||
{% trans %}
|
||||
Emails sent! You will only receive emails at addresses
|
||||
associated with Zulip organizations. The addresses entered
|
||||
on the previous page are listed below:
|
||||
Emails sent! The addresses entered on the previous page are listed below:
|
||||
{% endtrans %}
|
||||
</p>
|
||||
|
||||
|
|
|
@ -56,9 +56,7 @@ class EmailTranslationTestCase(ZulipTestCase):
|
|||
{"email": "new-email@zulip.com"},
|
||||
HTTP_ACCEPT_LANGUAGE="pt",
|
||||
)
|
||||
check_translation(
|
||||
"Danke, dass du", "post", "/accounts/find/", {"emails": hamlet.delivery_email}
|
||||
)
|
||||
check_translation("Danke für", "post", "/accounts/find/", {"emails": hamlet.delivery_email})
|
||||
check_translation(
|
||||
"Hallo",
|
||||
"post",
|
||||
|
|
|
@ -4253,7 +4253,7 @@ class TestFindMyTeam(ZulipTestCase):
|
|||
)
|
||||
self.assertEqual(result.status_code, 200)
|
||||
content = result.content.decode()
|
||||
self.assertIn("Emails sent! You will only receive emails", content)
|
||||
self.assertIn("Emails sent! The addresses entered on", content)
|
||||
self.assertIn("iago@zulip.com", content)
|
||||
self.assertIn("cordeliA@zulip.com", content)
|
||||
from django.core.mail import outbox
|
||||
|
@ -4266,18 +4266,17 @@ class TestFindMyTeam(ZulipTestCase):
|
|||
self.assertIn("Zulip Dev", cordelia_message.body)
|
||||
self.assertIn("Lear & Co", cordelia_message.body)
|
||||
|
||||
def test_find_team_ignore_invalid_email(self) -> None:
|
||||
result = self.client_post(
|
||||
"/accounts/find/", dict(emails="iago@zulip.com,invalid_email@zulip.com")
|
||||
)
|
||||
def test_find_team_email_with_no_account(self) -> None:
|
||||
result = self.client_post("/accounts/find/", dict(emails="no_account_email@zulip.com"))
|
||||
self.assertEqual(result.status_code, 200)
|
||||
content = result.content.decode()
|
||||
self.assertIn("Emails sent! You will only receive emails", content)
|
||||
self.assertIn(self.example_email("iago"), content)
|
||||
self.assertIn("invalid_email@", content)
|
||||
self.assertIn("Emails sent! The addresses entered on", content)
|
||||
self.assertIn("no_account_email@", content)
|
||||
from django.core.mail import outbox
|
||||
|
||||
self.assert_length(outbox, 1)
|
||||
message = outbox[0]
|
||||
self.assertIn("Unfortunately, no accounts", message.body)
|
||||
|
||||
def test_find_team_reject_invalid_email(self) -> None:
|
||||
result = self.client_post("/accounts/find/", dict(emails="invalid_string"))
|
||||
|
@ -4307,6 +4306,8 @@ class TestFindMyTeam(ZulipTestCase):
|
|||
from django.core.mail import outbox
|
||||
|
||||
self.assert_length(outbox, 1)
|
||||
message = outbox[0]
|
||||
self.assertIn("Zulip Dev", message.body)
|
||||
|
||||
def test_find_team_deactivated_user(self) -> None:
|
||||
do_deactivate_user(self.example_user("hamlet"), acting_user=None)
|
||||
|
@ -4315,7 +4316,9 @@ class TestFindMyTeam(ZulipTestCase):
|
|||
self.assertEqual(result.status_code, 200)
|
||||
from django.core.mail import outbox
|
||||
|
||||
self.assert_length(outbox, 0)
|
||||
self.assert_length(outbox, 1)
|
||||
message = outbox[0]
|
||||
self.assertIn("Unfortunately, no accounts", message.body)
|
||||
|
||||
def test_find_team_deactivated_realm(self) -> None:
|
||||
do_deactivate_realm(get_realm("zulip"), acting_user=None)
|
||||
|
@ -4324,7 +4327,9 @@ class TestFindMyTeam(ZulipTestCase):
|
|||
self.assertEqual(result.status_code, 200)
|
||||
from django.core.mail import outbox
|
||||
|
||||
self.assert_length(outbox, 0)
|
||||
self.assert_length(outbox, 1)
|
||||
message = outbox[0]
|
||||
self.assertIn("Unfortunately, no accounts", message.body)
|
||||
|
||||
def test_find_team_bot_email(self) -> None:
|
||||
data = {"emails": self.example_email("webhook_bot")}
|
||||
|
@ -4332,7 +4337,9 @@ class TestFindMyTeam(ZulipTestCase):
|
|||
self.assertEqual(result.status_code, 200)
|
||||
from django.core.mail import outbox
|
||||
|
||||
self.assert_length(outbox, 0)
|
||||
self.assert_length(outbox, 1)
|
||||
message = outbox[0]
|
||||
self.assertIn("Unfortunately, no accounts", message.body)
|
||||
|
||||
def test_find_team_more_than_ten_emails(self) -> None:
|
||||
data = {"emails": ",".join(f"hamlet-{i}@zulip.com" for i in range(11))}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import logging
|
||||
from contextlib import suppress
|
||||
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
|
||||
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple, Union
|
||||
from urllib.parse import urlencode, urljoin
|
||||
|
||||
import orjson
|
||||
|
@ -1134,6 +1134,7 @@ def find_account(request: HttpRequest) -> HttpResponse:
|
|||
# one outgoing email per provided email address, with each
|
||||
# email listing all of the accounts that email address has
|
||||
# with the current Zulip server.
|
||||
emails_account_found: Set[str] = set()
|
||||
context: Dict[str, Dict[str, Any]] = {}
|
||||
for user in user_profiles:
|
||||
key = user.delivery_email.lower()
|
||||
|
@ -1144,6 +1145,7 @@ def find_account(request: HttpRequest) -> HttpResponse:
|
|||
# matching accounts; since it's only used for minor
|
||||
# details like language, that arbitrary choice is OK.
|
||||
context[key]["to_user_id"] = user.id
|
||||
emails_account_found.add(user.delivery_email)
|
||||
|
||||
# Links in find_team emails use the server's information
|
||||
# and not any particular realm's information.
|
||||
|
@ -1152,12 +1154,15 @@ def find_account(request: HttpRequest) -> HttpResponse:
|
|||
help_reset_password_link = (
|
||||
f"{help_base_url}/change-your-password#if-youve-forgotten-or-never-had-a-password"
|
||||
)
|
||||
help_logging_in_link = f"{help_base_url}/logging-in#find-the-zulip-log-in-url"
|
||||
find_accounts_link = f"{external_host_base_url}/accounts/find/"
|
||||
|
||||
for delivery_email, realm_context in context.items():
|
||||
send_email(
|
||||
"zerver/emails/find_team",
|
||||
to_user_ids=[realm_context["to_user_id"]],
|
||||
context={
|
||||
"account_found": True,
|
||||
"external_host": settings.EXTERNAL_HOST,
|
||||
"corporate_enabled": settings.CORPORATE_ENABLED,
|
||||
"help_reset_password_link": help_reset_password_link,
|
||||
|
@ -1167,6 +1172,27 @@ def find_account(request: HttpRequest) -> HttpResponse:
|
|||
from_address=FromAddress.SUPPORT,
|
||||
request=request,
|
||||
)
|
||||
|
||||
emails_lower_with_account = {email.lower() for email in emails_account_found}
|
||||
emails_without_account: Set[str] = {
|
||||
email for email in emails if email.lower() not in emails_lower_with_account
|
||||
}
|
||||
if emails_without_account:
|
||||
send_email(
|
||||
"zerver/emails/find_team",
|
||||
to_emails=list(emails_without_account),
|
||||
context=(
|
||||
{
|
||||
"account_found": False,
|
||||
"external_host": settings.EXTERNAL_HOST,
|
||||
"corporate_enabled": settings.CORPORATE_ENABLED,
|
||||
"find_accounts_link": find_accounts_link,
|
||||
"help_logging_in_link": help_logging_in_link,
|
||||
}
|
||||
),
|
||||
from_address=FromAddress.SUPPORT,
|
||||
request=request,
|
||||
)
|
||||
return render(
|
||||
request,
|
||||
"zerver/find_account.html",
|
||||
|
|
Loading…
Reference in New Issue