diff options
author | Jonathan de Jong <jonathandejong02@gmail.com> | 2020-09-17 12:54:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-17 11:54:56 +0100 |
commit | 53284c425e219fbd9ae445bbe4a8628883a3631d (patch) | |
tree | b3f920c760fe967bc9367ce45fb184af1b2eea9f /synapse/rest/client/v2_alpha/register.py | |
parent | Switch metaclass initialization to python 3-compatible syntax (#8326) (diff) | |
download | synapse-53284c425e219fbd9ae445bbe4a8628883a3631d.tar.xz |
Fix a potential bug of UnboundLocalError (#8329)
Replaced with less buggier control flow
Diffstat (limited to 'synapse/rest/client/v2_alpha/register.py')
-rw-r--r-- | synapse/rest/client/v2_alpha/register.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/synapse/rest/client/v2_alpha/register.py b/synapse/rest/client/v2_alpha/register.py index b6b90a8b30..0705718d00 100644 --- a/synapse/rest/client/v2_alpha/register.py +++ b/synapse/rest/client/v2_alpha/register.py @@ -431,11 +431,14 @@ class RegisterRestServlet(RestServlet): access_token = self.auth.get_access_token_from_request(request) - if isinstance(desired_username, str): - result = await self._do_appservice_registration( - desired_username, access_token, body - ) - return 200, result # we throw for non 200 responses + if not isinstance(desired_username, str): + raise SynapseError(400, "Desired Username is missing or not a string") + + result = await self._do_appservice_registration( + desired_username, access_token, body + ) + + return 200, result # == Normal User Registration == (everyone else) if not self._registration_enabled: |