summary refs log tree commit diff
path: root/synapse/storage/registration.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-03-25 17:15:20 +0000
committerErik Johnston <erik@matrix.org>2015-03-25 17:15:20 +0000
commit0e8f5095c7e7075b249ad53a9f60a4d2fdeeaaed (patch)
tree39bdcca49ae0eabf09b3a98e2c4b810e0c68692f /synapse/storage/registration.py
parentEscape non printing ascii character (diff)
downloadsynapse-0e8f5095c7e7075b249ad53a9f60a4d2fdeeaaed.tar.xz
Fix unicode database support
Diffstat (limited to 'synapse/storage/registration.py')
-rw-r--r--synapse/storage/registration.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py
index fe26d6d62f..7258f7b2a5 100644
--- a/synapse/storage/registration.py
+++ b/synapse/storage/registration.py
@@ -81,13 +81,23 @@ class RegistrationStore(SQLBaseStore):
         txn.execute("INSERT INTO access_tokens(user_id, token) " +
                     "VALUES (?,?)", [user_id, token])
 
+    @defer.inlineCallbacks
     def get_user_by_id(self, user_id):
-        query = ("SELECT users.name, users.password_hash FROM users"
-                 " WHERE users.name = ?")
-        return self._execute(
-            "get_user_by_id", self.cursor_to_dict, query, user_id
+        user_info = yield self._simple_select_one(
+            table="users",
+            keyvalues={
+                "name": user_id,
+            },
+            retcols=["name", "password_hash"],
+            allow_none=True,
         )
 
+        if user_info:
+            user_info["password_hash"] = user_info["password_hash"].decode("utf8")
+
+        defer.returnValue(user_info)
+
+
     @cached()
     # TODO(paul): Currently there's no code to invalidate this cache. That
     #   means if/when we ever add internal ways to invalidate access tokens or