mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-16 16:30:13 -04:00
Fix inconsistent handling of upper and lower cases of email addresses. (#7021)
fixes #7016
This commit is contained in:
parent
8097659f6e
commit
21a212f8e5
8 changed files with 282 additions and 51 deletions
|
@ -47,7 +47,7 @@ from synapse.push.mailer import load_jinja2_templates
|
|||
from synapse.util.msisdn import phone_number_to_msisdn
|
||||
from synapse.util.ratelimitutils import FederationRateLimiter
|
||||
from synapse.util.stringutils import assert_valid_client_secret, random_string
|
||||
from synapse.util.threepids import check_3pid_allowed
|
||||
from synapse.util.threepids import canonicalise_email, check_3pid_allowed
|
||||
|
||||
from ._base import client_patterns, interactive_auth_handler
|
||||
|
||||
|
@ -116,7 +116,14 @@ class EmailRegisterRequestTokenRestServlet(RestServlet):
|
|||
client_secret = body["client_secret"]
|
||||
assert_valid_client_secret(client_secret)
|
||||
|
||||
email = body["email"]
|
||||
# For emails, canonicalise the address.
|
||||
# We store all email addresses canonicalised in the DB.
|
||||
# (See on_POST in EmailThreepidRequestTokenRestServlet
|
||||
# in synapse/rest/client/v2_alpha/account.py)
|
||||
try:
|
||||
email = canonicalise_email(body["email"])
|
||||
except ValueError as e:
|
||||
raise SynapseError(400, str(e))
|
||||
send_attempt = body["send_attempt"]
|
||||
next_link = body.get("next_link") # Optional param
|
||||
|
||||
|
@ -128,7 +135,7 @@ class EmailRegisterRequestTokenRestServlet(RestServlet):
|
|||
)
|
||||
|
||||
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:
|
||||
|
@ -552,6 +559,15 @@ class RegisterRestServlet(RestServlet):
|
|||
if login_type in auth_result:
|
||||
medium = auth_result[login_type]["medium"]
|
||||
address = auth_result[login_type]["address"]
|
||||
# For emails, canonicalise the address.
|
||||
# We store all email addresses canonicalised in the DB.
|
||||
# (See on_POST in EmailThreepidRequestTokenRestServlet
|
||||
# in synapse/rest/client/v2_alpha/account.py)
|
||||
if medium == "email":
|
||||
try:
|
||||
address = canonicalise_email(address)
|
||||
except ValueError as e:
|
||||
raise SynapseError(400, str(e))
|
||||
|
||||
existing_user_id = await self.store.get_user_id_by_threepid(
|
||||
medium, address
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue