Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Printf-debugging around MSDIDN validation
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson committed Feb 1, 2022
1 parent 6705391 commit 574b4ff
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions synapse/rest/client/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,12 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:

msisdn = phone_number_to_msisdn(country, phone_number)

# Didn't like the sound of logging `client_secret`, but the spec says it is
# "A unique string generated by the client, and used to identify the validation
# attempt." I.e. something to facilitate deduplication. I don't think it's a
# sensitive secret per se.
logger.info("Request to verify ownership of %s: %s", msisdn, body)

if not check_3pid_allowed(self.hs, "msisdn", msisdn):
raise SynapseError(
403,
Expand All @@ -494,6 +500,7 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
await self.hs.get_clock().sleep(random.randint(1, 10) / 10)
return 200, {"sid": random_string(16)}

logger.info("MSISDN %s is already in use by %s", msisdn, existing_user_id)
raise SynapseError(400, "MSISDN is already in use", Codes.THREEPID_IN_USE)

if not self.hs.config.registration.account_threepid_delegate_msisdn:
Expand All @@ -518,6 +525,7 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
threepid_send_requests.labels(type="msisdn", reason="add_threepid").observe(
send_attempt
)
logger.info("MSISDN %s is already in use by %s", msisdn, existing_user_id)

return 200, ret

Expand Down

0 comments on commit 574b4ff

Please sign in to comment.