summary refs log tree commit diff
path: root/synapse/storage/registration.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-03-20 16:31:48 +0000
committerErik Johnston <erik@matrix.org>2015-03-20 16:31:48 +0000
commitf6583796feeff5a50c0988ce674a1ab861b14e34 (patch)
tree47f9d5934440eef201c6ab65a0fb8df06631d18d /synapse/storage/registration.py
parentRearrange storage modules (diff)
parentMerge pull request #113 from matrix-org/store_rearrangement (diff)
downloadsynapse-f6583796feeff5a50c0988ce674a1ab861b14e34.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into mysql
Diffstat (limited to 'synapse/storage/registration.py')
-rw-r--r--synapse/storage/registration.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py
index 344dd3aaac..fe26d6d62f 100644
--- a/synapse/storage/registration.py
+++ b/synapse/storage/registration.py
@@ -19,7 +19,7 @@ from sqlite3 import IntegrityError
 
 from synapse.api.errors import StoreError, Codes
 
-from ._base import SQLBaseStore
+from ._base import SQLBaseStore, cached
 
 
 class RegistrationStore(SQLBaseStore):
@@ -44,7 +44,8 @@ class RegistrationStore(SQLBaseStore):
             {
                 "user_id": user_id,
                 "token": token
-            }
+            },
+            desc="add_access_token_to_user",
         )
 
     @defer.inlineCallbacks
@@ -87,6 +88,11 @@ class RegistrationStore(SQLBaseStore):
             "get_user_by_id", self.cursor_to_dict, query, user_id
         )
 
+    @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
+    #   change whether a user is a server admin, those will need to invoke
+    #      store.get_user_by_token.invalidate(token)
     def get_user_by_token(self, token):
         """Get a user from the given access token.
 
@@ -111,6 +117,7 @@ class RegistrationStore(SQLBaseStore):
             keyvalues={"name": user.to_string()},
             retcol="admin",
             allow_none=True,
+            desc="is_server_admin",
         )
 
         defer.returnValue(res if res else False)