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

Commit

Permalink
Make sure we're not registering the same 3pid twice
Browse files Browse the repository at this point in the history
  • Loading branch information
babolivier committed Apr 17, 2019
1 parent 35442ef commit 600ec04
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/5071.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make sure we're not registering the same 3pid twice on registration.
18 changes: 18 additions & 0 deletions synapse/rest/client/v2_alpha/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,13 @@ def on_POST(self, request):
# the user-facing checks will probably already have happened in
# /register/email/requestToken when we requested a 3pid, but that's not
# guaranteed.
#
# Also check that we're not trying to register a 3pid that's already
# been registered.
#
# This has probably happened in /register/email/requestToken as well,
# but if a user hits this endpoint twice then clicks on each link from
# the two activation emails, they would register the same 3pid twice.

if auth_result:
for login_type in [LoginType.EMAIL_IDENTITY, LoginType.MSISDN]:
Expand All @@ -406,6 +413,17 @@ def on_POST(self, request):
Codes.THREEPID_DENIED,
)

existingUid = yield self.store.get_user_id_by_threepid(
medium, address,
)

if existingUid is not None:
raise SynapseError(
400,
"%s is already in use" % medium,
Codes.THREEPID_IN_USE,
)

if registered_user_id is not None:
logger.info(
"Already registered user ID %r for this session",
Expand Down

0 comments on commit 600ec04

Please sign in to comment.