mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Make sure we're not registering the same 3pid twice
This commit is contained in:
parent
35442efb75
commit
600ec04739
1
changelog.d/5071.bugfix
Normal file
1
changelog.d/5071.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Make sure we're not registering the same 3pid twice on registration.
|
@ -391,6 +391,13 @@ class RegisterRestServlet(RestServlet):
|
|||||||
# the user-facing checks will probably already have happened in
|
# the user-facing checks will probably already have happened in
|
||||||
# /register/email/requestToken when we requested a 3pid, but that's not
|
# /register/email/requestToken when we requested a 3pid, but that's not
|
||||||
# guaranteed.
|
# 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:
|
if auth_result:
|
||||||
for login_type in [LoginType.EMAIL_IDENTITY, LoginType.MSISDN]:
|
for login_type in [LoginType.EMAIL_IDENTITY, LoginType.MSISDN]:
|
||||||
@ -406,6 +413,17 @@ class RegisterRestServlet(RestServlet):
|
|||||||
Codes.THREEPID_DENIED,
|
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:
|
if registered_user_id is not None:
|
||||||
logger.info(
|
logger.info(
|
||||||
"Already registered user ID %r for this session",
|
"Already registered user ID %r for this session",
|
||||||
|
Loading…
Reference in New Issue
Block a user