summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2016-07-18 10:44:56 +0100
committerGitHub <noreply@github.com>2016-07-18 10:44:56 +0100
commit4f81edbd4f5ecaab9a1abb6422c5a6fc28b84a7a (patch)
tree8f767e663b09d874efd565037ac2db96660c330a
parentFix a doc-comment (diff)
parentUse body.get to check for 'user' (diff)
downloadsynapse-4f81edbd4f5ecaab9a1abb6422c5a6fc28b84a7a.tar.xz
Merge pull request #927 from Half-Shot/develop
Fall back to 'username' if 'user' is not given for appservice registration.
-rw-r--r--synapse/rest/client/v2_alpha/register.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/synapse/rest/client/v2_alpha/register.py b/synapse/rest/client/v2_alpha/register.py
index 7c6d2942dc..e8d34b06b0 100644
--- a/synapse/rest/client/v2_alpha/register.py
+++ b/synapse/rest/client/v2_alpha/register.py
@@ -132,11 +132,12 @@ class RegisterRestServlet(RestServlet):
             # Set the desired user according to the AS API (which uses the
             # 'user' key not 'username'). Since this is a new addition, we'll
             # fallback to 'username' if they gave one.
-            if isinstance(body.get("user"), basestring):
-                desired_username = body["user"]
-            result = yield self._do_appservice_registration(
-                desired_username, request.args["access_token"][0]
-            )
+            desired_username = body.get("user", desired_username)
+
+            if isinstance(desired_username, basestring):
+                result = yield self._do_appservice_registration(
+                    desired_username, request.args["access_token"][0]
+                )
             defer.returnValue((200, result))  # we throw for non 200 responses
             return