diff options
author | David Baker <dave@matrix.org> | 2016-03-16 19:36:57 +0000 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2016-03-16 19:36:57 +0000 |
commit | a7daa5ae131cc860769d859cf03b48cefdc0500a (patch) | |
tree | 6e07ec369ee1fe7e92bd1a1a8822dbee73958a0b /synapse/handlers/register.py | |
parent | Merge pull request #649 from matrix-org/dbkr/idempotent_registration (diff) | |
download | synapse-a7daa5ae131cc860769d859cf03b48cefdc0500a.tar.xz |
Make registration idempotent, part 2: be idempotent if the client specifies a username.
Diffstat (limited to 'synapse/handlers/register.py')
-rw-r--r-- | synapse/handlers/register.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py index 6ffb8c0da6..f287ee247b 100644 --- a/synapse/handlers/register.py +++ b/synapse/handlers/register.py @@ -47,7 +47,8 @@ class RegistrationHandler(BaseHandler): self._next_generated_user_id = None @defer.inlineCallbacks - def check_username(self, localpart, guest_access_token=None): + def check_username(self, localpart, guest_access_token=None, + assigned_user_id=None): yield run_on_reactor() if urllib.quote(localpart.encode('utf-8')) != localpart: @@ -60,6 +61,15 @@ class RegistrationHandler(BaseHandler): user = UserID(localpart, self.hs.hostname) user_id = user.to_string() + if assigned_user_id: + if user_id == assigned_user_id: + return + else: + raise SynapseError( + 400, + "A different user ID has already been registered for this session", + ) + yield self.check_user_id_not_appservice_exclusive(user_id) users = yield self.store.get_users_by_id_case_insensitive(user_id) |