|
26 | 26 | SynapseError, |
27 | 27 | ) |
28 | 28 | from synapse.api.ratelimiting import Ratelimiter |
29 | | -from synapse.config.emailconfig import ThreepidBehaviour |
30 | 29 | from synapse.http import RequestTimedOutError |
31 | 30 | from synapse.http.client import SimpleHttpClient |
32 | 31 | from synapse.http.site import SynapseRequest |
@@ -434,48 +433,6 @@ async def send_threepid_validation( |
434 | 433 |
|
435 | 434 | return session_id |
436 | 435 |
|
437 | | - async def requestEmailToken( |
438 | | - self, |
439 | | - id_server: str, |
440 | | - email: str, |
441 | | - client_secret: str, |
442 | | - send_attempt: int, |
443 | | - next_link: Optional[str] = None, |
444 | | - ) -> JsonDict: |
445 | | - """ |
446 | | - Request an external server send an email on our behalf for the purposes of threepid |
447 | | - validation. |
448 | | -
|
449 | | - Args: |
450 | | - id_server: The identity server to proxy to |
451 | | - email: The email to send the message to |
452 | | - client_secret: The unique client_secret sends by the user |
453 | | - send_attempt: Which attempt this is |
454 | | - next_link: A link to redirect the user to once they submit the token |
455 | | -
|
456 | | - Returns: |
457 | | - The json response body from the server |
458 | | - """ |
459 | | - params = { |
460 | | - "email": email, |
461 | | - "client_secret": client_secret, |
462 | | - "send_attempt": send_attempt, |
463 | | - } |
464 | | - if next_link: |
465 | | - params["next_link"] = next_link |
466 | | - |
467 | | - try: |
468 | | - data = await self.http_client.post_json_get_json( |
469 | | - id_server + "/_matrix/identity/api/v1/validate/email/requestToken", |
470 | | - params, |
471 | | - ) |
472 | | - return data |
473 | | - except HttpResponseException as e: |
474 | | - logger.info("Proxied requestToken failed: %r", e) |
475 | | - raise e.to_synapse_error() |
476 | | - except RequestTimedOutError: |
477 | | - raise SynapseError(500, "Timed out contacting identity server") |
478 | | - |
479 | 436 | async def requestMsisdnToken( |
480 | 437 | self, |
481 | 438 | id_server: str, |
@@ -549,18 +506,7 @@ async def validate_threepid_session( |
549 | 506 | validation_session = None |
550 | 507 |
|
551 | 508 | # Try to validate as email |
552 | | - if self.hs.config.email.threepid_behaviour_email == ThreepidBehaviour.REMOTE: |
553 | | - # Remote emails will only be used if a valid identity server is provided. |
554 | | - assert ( |
555 | | - self.hs.config.registration.account_threepid_delegate_email is not None |
556 | | - ) |
557 | | - |
558 | | - # Ask our delegated email identity server |
559 | | - validation_session = await self.threepid_from_creds( |
560 | | - self.hs.config.registration.account_threepid_delegate_email, |
561 | | - threepid_creds, |
562 | | - ) |
563 | | - elif self.hs.config.email.threepid_behaviour_email == ThreepidBehaviour.LOCAL: |
| 509 | + if self.hs.config.email.can_verify_email: |
564 | 510 | # Get a validated session matching these details |
565 | 511 | validation_session = await self.store.get_threepid_validation_session( |
566 | 512 | "email", client_secret, sid=sid, validated=True |
|
0 commit comments