summary refs log tree commit diff
path: root/synapse/storage/registration.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2017-11-01 15:42:38 +0000
committerRichard van der Hoff <richard@matrix.org>2017-11-01 16:51:51 +0000
commitbc8a5c033097f719d6b2971660ad833ab8cb3838 (patch)
treea04182e6c7ed25ce0f2362a6fd6e7427973fbd03 /synapse/storage/registration.py
parentMerge pull request #2620 from matrix-org/rav/auth_non_password (diff)
downloadsynapse-bc8a5c033097f719d6b2971660ad833ab8cb3838.tar.xz
Notify auth providers on logout
Provide a hook by which auth providers can be notified of logouts.
Diffstat (limited to '')
-rw-r--r--synapse/storage/registration.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py
index 65ddefda92..9c4f61da76 100644
--- a/synapse/storage/registration.py
+++ b/synapse/storage/registration.py
@@ -255,7 +255,8 @@ class RegistrationStore(background_updates.BackgroundUpdateStore):
                 If None, tokens associated with any device (or no device) will
                 be deleted
         Returns:
-            defer.Deferred:
+            defer.Deferred[list[str, str|None]]: a list of the deleted tokens
+                and device IDs
         """
         def f(txn):
             keyvalues = {
@@ -272,14 +273,14 @@ class RegistrationStore(background_updates.BackgroundUpdateStore):
                 values.append(except_token_id)
 
             txn.execute(
-                "SELECT token FROM access_tokens WHERE %s" % where_clause,
+                "SELECT token, device_id FROM access_tokens WHERE %s" % where_clause,
                 values
             )
-            rows = self.cursor_to_dict(txn)
+            tokens_and_devices = [(r[0], r[1]) for r in txn]
 
-            for row in rows:
+            for token, _ in tokens_and_devices:
                 self._invalidate_cache_and_stream(
-                    txn, self.get_user_by_access_token, (row["token"],)
+                    txn, self.get_user_by_access_token, (token,)
                 )
 
             txn.execute(
@@ -287,6 +288,8 @@ class RegistrationStore(background_updates.BackgroundUpdateStore):
                 values
             )
 
+            return tokens_and_devices
+
         yield self.runInteraction(
             "user_delete_access_tokens", f,
         )