Skip to content
Snippets Groups Projects
Commit 55bc8d53 authored by Andrew Morgan's avatar Andrew Morgan
Browse files

raise exception after multiple failures

parent 1fe3cc2c
No related branches found
No related tags found
No related merge requests found
...@@ -217,8 +217,13 @@ class RegistrationHandler(BaseHandler): ...@@ -217,8 +217,13 @@ class RegistrationHandler(BaseHandler):
else: else:
# autogen a sequential user ID # autogen a sequential user ID
# Fail after being unable to find a suitable ID a few times fail_count = 0
for x in range(10): user = None
while not user:
# Fail after being unable to find a suitable ID a few times
if fail_count > 10:
raise SynapseError(500, "Unable to find a suitable guest user ID")
localpart = yield self._generate_user_id() localpart = yield self._generate_user_id()
user = UserID(localpart, self.hs.hostname) user = UserID(localpart, self.hs.hostname)
user_id = user.to_string() user_id = user.to_string()
...@@ -238,7 +243,9 @@ class RegistrationHandler(BaseHandler): ...@@ -238,7 +243,9 @@ class RegistrationHandler(BaseHandler):
break break
except SynapseError: except SynapseError:
# if user id is taken, just generate another # if user id is taken, just generate another
pass user = None
user_id = None
fail_count += 1
if not self.hs.config.user_consent_at_registration: if not self.hs.config.user_consent_at_registration:
yield self._auto_join_rooms(user_id) yield self._auto_join_rooms(user_id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment