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

Commit

Permalink
Fix inconsistent handling of upper and lower cases of email addresses.
Browse files Browse the repository at this point in the history
  • Loading branch information
dklimpel committed Mar 2, 2020
1 parent b29474e commit ced5716
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog.d/7016.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix inconsistent handling of upper and lower cases of email addresses that is use only lower cases.
12 changes: 9 additions & 3 deletions synapse/rest/client/v2_alpha/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ async def on_POST(self, request):
client_secret = body["client_secret"]
assert_valid_client_secret(client_secret)

email = body["email"]
# For emails, transform the address to lowercase.
# We store all email addreses as lowercase in the DB.
# (See add_threepid in synapse/handlers/auth.py)
email = body["email"].lower()
send_attempt = body["send_attempt"]
next_link = body.get("next_link") # Optional param

Expand Down Expand Up @@ -359,7 +362,10 @@ async def on_POST(self, request):
client_secret = body["client_secret"]
assert_valid_client_secret(client_secret)

email = body["email"]
# For emails, transform the address to lowercase.
# We store all email addreses as lowercase in the DB.
# (See add_threepid in synapse/handlers/auth.py)
email = body["email"].lower()
send_attempt = body["send_attempt"]
next_link = body.get("next_link") # Optional param

Expand All @@ -371,7 +377,7 @@ async def on_POST(self, request):
)

existing_user_id = await self.store.get_user_id_by_threepid(
"email", body["email"]
"email", email
)

if existing_user_id is not None:
Expand Down
12 changes: 9 additions & 3 deletions synapse/rest/client/v2_alpha/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ async def on_POST(self, request):
client_secret = body["client_secret"]
assert_valid_client_secret(client_secret)

email = body["email"]
# For emails, transform the address to lowercase.
# We store all email addreses as lowercase in the DB.
# (See add_threepid in synapse/handlers/auth.py)
email = body["email"].lower()
send_attempt = body["send_attempt"]
next_link = body.get("next_link") # Optional param

Expand All @@ -131,7 +134,7 @@ async def on_POST(self, request):
)

existing_user_id = await self.hs.get_datastore().get_user_id_by_threepid(
"email", body["email"]
"email", email
)

if existing_user_id is not None:
Expand Down Expand Up @@ -552,7 +555,10 @@ async def on_POST(self, request):
for login_type in [LoginType.EMAIL_IDENTITY, LoginType.MSISDN]:
if login_type in auth_result:
medium = auth_result[login_type]["medium"]
address = auth_result[login_type]["address"]
# For emails, transform the address to lowercase.
# We store all email addreses as lowercase in the DB.
# (See add_threepid in synapse/handlers/auth.py)
address = auth_result[login_type]["address"].lower()

existing_user_id = await self.store.get_user_id_by_threepid(
medium, address
Expand Down

0 comments on commit ced5716

Please sign in to comment.