mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-06 11:04:11 -04:00
Make registration idempotent, part 2: be idempotent if the client specifies a username.
This commit is contained in:
parent
48b2e853a8
commit
a7daa5ae13
3 changed files with 42 additions and 6 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue