summary refs log tree commit diff
path: root/synapse/rest
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-08-14 16:40:15 +0100
committerKegan Dougal <kegan@matrix.org>2014-08-14 16:40:15 +0100
commitfef3183461a60715cb5fb0638abcde335c61db82 (patch)
treed34d0aa0abee7536e19efd2bde8ddb637d7a1534 /synapse/rest
parenths: Make /login accept full user IDs or just local parts. webclient: Only ena... (diff)
downloadsynapse-fef3183461a60715cb5fb0638abcde335c61db82.tar.xz
Pass back the user_id in the response to /login in case it has changed. Store and use that on the webclient rather than the input field.
Diffstat (limited to 'synapse/rest')
-rw-r--r--synapse/rest/login.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/synapse/rest/login.py b/synapse/rest/login.py
index 88a3218332..bcf63fd2ab 100644
--- a/synapse/rest/login.py
+++ b/synapse/rest/login.py
@@ -16,6 +16,7 @@
 from twisted.internet import defer
 
 from synapse.api.errors import SynapseError
+from synapse.types import UserID
 from base import RestServlet, client_path_pattern
 
 import json
@@ -45,12 +46,17 @@ class LoginRestServlet(RestServlet):
 
     @defer.inlineCallbacks
     def do_password_login(self, login_submission):
+        if not login_submission["user"].startswith('@'):
+            login_submission["user"] = UserID.create_local(
+                login_submission["user"], self.hs).to_string()
+
         handler = self.handlers.login_handler
         token = yield handler.login(
             user=login_submission["user"],
             password=login_submission["password"])
 
         result = {
+            "user_id": login_submission["user"],  # may have changed
             "access_token": token,
             "home_server": self.hs.hostname,
         }