summary refs log tree commit diff
path: root/synapse/handlers/register.py
diff options
context:
space:
mode:
authorNegi Fazeli <negar.fazeli@ericsson.com>2016-05-23 11:14:11 +0200
committerNegi Fazeli <negar.fazeli@ericsson.com>2016-05-23 19:50:28 +0200
commit6fe04ffef2fd44a3af61fe262266b25158c46db7 (patch)
tree81945624db4b0adf5e52eb5be6b713cf69baf3fc /synapse/handlers/register.py
parentFix link to A-S spec (diff)
downloadsynapse-6fe04ffef2fd44a3af61fe262266b25158c46db7.tar.xz
Fix set profile error with Requester.
Replace flush_user with delete access token due to function removal
Add a new test case for if the user is already registered
Diffstat (limited to 'synapse/handlers/register.py')
-rw-r--r--synapse/handlers/register.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py
index 5883b9111e..16f33f8371 100644
--- a/synapse/handlers/register.py
+++ b/synapse/handlers/register.py
@@ -16,7 +16,7 @@
 """Contains functions for registering clients."""
 from twisted.internet import defer
 
-from synapse.types import UserID
+from synapse.types import UserID, Requester
 from synapse.api.errors import (
     AuthError, Codes, SynapseError, RegistrationError, InvalidCaptchaError
 )
@@ -360,7 +360,8 @@ class RegistrationHandler(BaseHandler):
 
     @defer.inlineCallbacks
     def get_or_create_user(self, localpart, displayname, duration_seconds):
-        """Creates a new user or returns an access token for an existing one
+        """Creates a new user if the user does not exist,
+        else revokes all previous access tokens and generates a new one.
 
         Args:
             localpart : The local part of the user ID to register. If None,
@@ -399,14 +400,14 @@ class RegistrationHandler(BaseHandler):
 
             yield registered_user(self.distributor, user)
         else:
-            yield self.store.flush_user(user_id=user_id)
+            yield self.store.user_delete_access_tokens(user_id=user_id)
             yield self.store.add_access_token_to_user(user_id=user_id, token=token)
 
         if displayname is not None:
             logger.info("setting user display name: %s -> %s", user_id, displayname)
             profile_handler = self.hs.get_handlers().profile_handler
             yield profile_handler.set_displayname(
-                user, user, displayname
+                user, Requester(user, token, False), displayname
             )
 
         defer.returnValue((user_id, token))