|
30 | 30 | ) |
31 | 31 | from synapse.push.mailer import Mailer, load_jinja2_templates |
32 | 32 | from synapse.util.msisdn import phone_number_to_msisdn |
33 | | -from synapse.util.stringutils import assert_valid_client_secret |
| 33 | +from synapse.util.stringutils import assert_valid_client_secret, random_string |
34 | 34 | from synapse.util.threepids import check_3pid_allowed |
35 | 35 |
|
36 | 36 | from ._base import client_patterns, interactive_auth_handler |
@@ -100,6 +100,11 @@ async def on_POST(self, request): |
100 | 100 | ) |
101 | 101 |
|
102 | 102 | if existing_user_id is None: |
| 103 | + if self.config.request_token_inhibit_3pid_errors: |
| 104 | + # Make the client think the operation succeeded. See the rationale in the |
| 105 | + # comments for request_token_inhibit_3pid_errors. |
| 106 | + return 200, {"sid": random_string(16)} |
| 107 | + |
103 | 108 | raise SynapseError(400, "Email not found", Codes.THREEPID_NOT_FOUND) |
104 | 109 |
|
105 | 110 | if self.config.threepid_behaviour_email == ThreepidBehaviour.REMOTE: |
@@ -390,6 +395,11 @@ async def on_POST(self, request): |
390 | 395 | ) |
391 | 396 |
|
392 | 397 | if existing_user_id is not None: |
| 398 | + if self.config.request_token_inhibit_3pid_errors: |
| 399 | + # Make the client think the operation succeeded. See the rationale in the |
| 400 | + # comments for request_token_inhibit_3pid_errors. |
| 401 | + return 200, {"sid": random_string(16)} |
| 402 | + |
393 | 403 | raise SynapseError(400, "Email is already in use", Codes.THREEPID_IN_USE) |
394 | 404 |
|
395 | 405 | if self.config.threepid_behaviour_email == ThreepidBehaviour.REMOTE: |
@@ -453,6 +463,11 @@ async def on_POST(self, request): |
453 | 463 | existing_user_id = await self.store.get_user_id_by_threepid("msisdn", msisdn) |
454 | 464 |
|
455 | 465 | if existing_user_id is not None: |
| 466 | + if self.hs.config.request_token_inhibit_3pid_errors: |
| 467 | + # Make the client think the operation succeeded. See the rationale in the |
| 468 | + # comments for request_token_inhibit_3pid_errors. |
| 469 | + return 200, {"sid": random_string(16)} |
| 470 | + |
456 | 471 | raise SynapseError(400, "MSISDN is already in use", Codes.THREEPID_IN_USE) |
457 | 472 |
|
458 | 473 | if not self.hs.config.account_threepid_delegate_msisdn: |
|
0 commit comments