mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-22 17:46:08 +03:00
Fix a potential bug of UnboundLocalError (#8329)
Replaced with less buggier control flow
This commit is contained in:
parent
a3f124b821
commit
53284c425e
2 changed files with 9 additions and 5 deletions
1
changelog.d/8329.bugfix
Normal file
1
changelog.d/8329.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Fix UnboundLocalError from occuring when appservices send malformed register request.
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue