Skip to content

Commit d92f452

Browse files
3npYour Name
authored andcommitted
Revert "Send an email if the address is already bound to an user account (element-hq#16819)"
This reverts commit ae18123.
1 parent b30fcb0 commit d92f452

6 files changed

Lines changed: 2 additions & 69 deletions

File tree

synapse/config/emailconfig.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"invite_from_person_to_space": "[%(app)s] %(person)s has invited you to join the %(space)s space on %(app)s...",
5353
"password_reset": "[%(server_name)s] Password reset",
5454
"email_validation": "[%(server_name)s] Validate your email",
55-
"email_already_in_use": "[%(server_name)s] Email already in use",
5655
}
5756

5857
LEGACY_TEMPLATE_DIR_WARNING = """
@@ -77,7 +76,6 @@ class EmailSubjectConfig:
7776
invite_from_person_to_space: str
7877
password_reset: str
7978
email_validation: str
80-
email_already_in_use: str
8179

8280

8381
class EmailConfig(Config):
@@ -183,12 +181,6 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
183181
registration_template_text = email_config.get(
184182
"registration_template_text", "registration.txt"
185183
)
186-
already_in_use_template_html = email_config.get(
187-
"already_in_use_template_html", "already_in_use.html"
188-
)
189-
already_in_use_template_text = email_config.get(
190-
"already_in_use_template_html", "already_in_use.txt"
191-
)
192184
add_threepid_template_html = email_config.get(
193185
"add_threepid_template_html", "add_threepid.html"
194186
)
@@ -224,8 +216,6 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
224216
self.email_password_reset_template_text,
225217
self.email_registration_template_html,
226218
self.email_registration_template_text,
227-
self.email_already_in_use_template_html,
228-
self.email_already_in_use_template_text,
229219
self.email_add_threepid_template_html,
230220
self.email_add_threepid_template_text,
231221
self.email_password_reset_template_confirmation_html,
@@ -241,8 +231,6 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
241231
password_reset_template_text,
242232
registration_template_html,
243233
registration_template_text,
244-
already_in_use_template_html,
245-
already_in_use_template_text,
246234
add_threepid_template_html,
247235
add_threepid_template_text,
248236
"password_reset_confirmation.html",

synapse/push/mailer.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -205,22 +205,6 @@ async def send_registration_mail(
205205
template_vars,
206206
)
207207

208-
emails_sent_counter.labels("already_in_use")
209-
210-
async def send_already_in_use_mail(self, email_address: str) -> None:
211-
"""Send an email if the address is already bound to an user account
212-
213-
Args:
214-
email_address: Email address we're sending to the "already in use" mail
215-
"""
216-
217-
await self.send_email(
218-
email_address,
219-
self.email_subjects.email_already_in_use
220-
% {"server_name": self.hs.config.server.server_name, "app": self.app_name},
221-
{},
222-
)
223-
224208
emails_sent_counter.labels("add_threepid")
225209

226210
async def send_add_threepid_mail(

synapse/res/templates/already_in_use.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

synapse/res/templates/already_in_use.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

synapse/rest/client/register.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,12 @@ def __init__(self, hs: "HomeServer"):
8686
self.config = hs.config
8787

8888
if self.hs.config.email.can_verify_email:
89-
self.registration_mailer = Mailer(
89+
self.mailer = Mailer(
9090
hs=self.hs,
9191
app_name=self.config.email.email_app_name,
9292
template_html=self.config.email.email_registration_template_html,
9393
template_text=self.config.email.email_registration_template_text,
9494
)
95-
self.already_in_use_mailer = Mailer(
96-
hs=self.hs,
97-
app_name=self.config.email.email_app_name,
98-
template_html=self.config.email.email_already_in_use_template_html,
99-
template_text=self.config.email.email_already_in_use_template_text,
100-
)
10195

10296
async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
10397
if not self.hs.config.email.can_verify_email:
@@ -145,10 +139,8 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
145139
if self.hs.config.server.request_token_inhibit_3pid_errors:
146140
# Make the client think the operation succeeded. See the rationale in the
147141
# comments for request_token_inhibit_3pid_errors.
148-
# Still send an email to warn the user that an account already exists.
149142
# Also wait for some random amount of time between 100ms and 1s to make it
150143
# look like we did something.
151-
await self.already_in_use_mailer.send_already_in_use_mail(email)
152144
await self.hs.get_clock().sleep(random.randint(1, 10) / 10)
153145
return 200, {"sid": random_string(16)}
154146

@@ -159,7 +151,7 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
159151
email,
160152
client_secret,
161153
send_attempt,
162-
self.registration_mailer.send_registration_mail,
154+
self.mailer.send_registration_mail,
163155
next_link,
164156
)
165157

tests/rest/client/test_register.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import datetime
2323
import os
2424
from typing import Any, Dict, List, Tuple
25-
from unittest.mock import AsyncMock
2625

2726
import pkg_resources
2827

@@ -43,7 +42,6 @@
4342
from synapse.util import Clock
4443

4544
from tests import unittest
46-
from tests.server import ThreadedMemoryReactorClock
4745
from tests.unittest import override_config
4846

4947

@@ -60,13 +58,6 @@ def default_config(self) -> Dict[str, Any]:
6058
config["allow_guest_access"] = True
6159
return config
6260

63-
def make_homeserver(
64-
self, reactor: ThreadedMemoryReactorClock, clock: Clock
65-
) -> HomeServer:
66-
hs = super().make_homeserver(reactor, clock)
67-
hs.get_send_email_handler()._sendmail = AsyncMock()
68-
return hs
69-
7061
def test_POST_appservice_registration_valid(self) -> None:
7162
user_id = "@as_user_kermit:test"
7263
as_token = "i_am_an_app_service"

0 commit comments

Comments
 (0)