summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2016-07-21 11:34:16 +0100
committerRichard van der Hoff <richard@matrix.org>2016-07-21 11:34:16 +0100
commit1a64dffb00287a30c2d4992944836122bd4d8923 (patch)
treea9ff652b32252287e48e858adcc8db75a86e73e2 /synapse
parentMerge pull request #938 from matrix-org/rav/add_device_id_to_client_ips (diff)
downloadsynapse-1a64dffb00287a30c2d4992944836122bd4d8923.tar.xz
Preserve device_id from first call to /register
device_id may only be passed in the first call to /register, so make sure we
fish it out of the register `params` rather than the body of the final call.
Diffstat (limited to 'synapse')
-rw-r--r--synapse/rest/client/v2_alpha/register.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/synapse/rest/client/v2_alpha/register.py b/synapse/rest/client/v2_alpha/register.py
index d401722224..c8c9395fc6 100644
--- a/synapse/rest/client/v2_alpha/register.py
+++ b/synapse/rest/client/v2_alpha/register.py
@@ -237,7 +237,7 @@ class RegisterRestServlet(RestServlet):
             add_email = True
 
         result = yield self._create_registration_details(
-            registered_user_id, body
+            registered_user_id, params
         )
 
         if add_email and result and LoginType.EMAIL_IDENTITY in result:
@@ -359,7 +359,7 @@ class RegisterRestServlet(RestServlet):
         defer.returnValue()
 
     @defer.inlineCallbacks
-    def _create_registration_details(self, user_id, body):
+    def _create_registration_details(self, user_id, params):
         """Complete registration of newly-registered user
 
         Allocates device_id if one was not given; also creates access_token
@@ -367,13 +367,12 @@ class RegisterRestServlet(RestServlet):
 
         Args:
             (str) user_id: full canonical @user:id
-            (object) body: dictionary supplied to /register call, from
-               which we pull device_id and initial_device_name
-
+            (object) params: registration parameters, from which we pull
+                device_id and initial_device_name
         Returns:
             defer.Deferred: (object) dictionary for response from /register
         """
-        device_id = yield self._register_device(user_id, body)
+        device_id = yield self._register_device(user_id, params)
 
         access_token = yield self.auth_handler.issue_access_token(
             user_id, device_id=device_id
@@ -390,7 +389,7 @@ class RegisterRestServlet(RestServlet):
             "device_id": device_id,
         })
 
-    def _register_device(self, user_id, body):
+    def _register_device(self, user_id, params):
         """Register a device for a user.
 
         This is called after the user's credentials have been validated, but
@@ -398,14 +397,14 @@ class RegisterRestServlet(RestServlet):
 
         Args:
             (str) user_id: full canonical @user:id
-            (object) body: dictionary supplied to /register call, from
-               which we pull device_id and initial_device_name
+            (object) params: registration parameters, from which we pull
+                device_id and initial_device_name
         Returns:
             defer.Deferred: (str) device_id
         """
         # register the user's device
-        device_id = body.get("device_id")
-        initial_display_name = body.get("initial_device_display_name")
+        device_id = params.get("device_id")
+        initial_display_name = params.get("initial_device_display_name")
         device_id = self.device_handler.check_device_registered(
             user_id, device_id, initial_display_name
         )