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

Commit

Permalink
Allow for old and new key name
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 committed Jun 12, 2020
1 parent 90c714d commit 91c1b70
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions synapse/rest/client/v1/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,18 @@ def login_id_thirdparty_from_phone(identifier):
Returns: Login identifier dict of type 'm.id.threepid'
"""
if "country" not in identifier or "phone" not in identifier:
if "country" not in identifier or (
# XXX: We used to require `number` instead of `phone`. The spec
# defines `phone`. So accept both
"phone" not in identifier
and "number" not in identifier
):
raise SynapseError(400, "Invalid phone-type identifier")

msisdn = phone_number_to_msisdn(identifier["country"], identifier["phone"])
# Accept both "phone" and "number" as valid keys in m.id.phone
phone_number = identifier.get("phone", identifier["number"])

msisdn = phone_number_to_msisdn(identifier["country"], phone_number)

return {"type": "m.id.thirdparty", "medium": "msisdn", "address": msisdn}

Expand Down

0 comments on commit 91c1b70

Please sign in to comment.