summary refs log tree commit diff
path: root/synapse/handlers/auth.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2017-11-29 14:33:05 +0000
committerRichard van der Hoff <richard@matrix.org>2017-11-29 16:44:35 +0000
commit2c6d63922a5033a17c7d53a928892fbbcbd6fa63 (patch)
tree5bc4aa7bfda91ea69cb9231e27a1e9bd9ee03b56 /synapse/handlers/auth.py
parentMerge pull request #2718 from matrix-org/rav/notify_logcontexts (diff)
downloadsynapse-2c6d63922a5033a17c7d53a928892fbbcbd6fa63.tar.xz
Remove pushers when deleting access tokens
Whenever an access token is invalidated, we should remove the associated
pushers.
Diffstat (limited to 'synapse/handlers/auth.py')
-rw-r--r--synapse/handlers/auth.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/synapse/handlers/auth.py b/synapse/handlers/auth.py
index 080eb14271..0ba66bc947 100644
--- a/synapse/handlers/auth.py
+++ b/synapse/handlers/auth.py
@@ -664,9 +664,6 @@ class AuthHandler(BaseHandler):
         yield self.delete_access_tokens_for_user(
             user_id, except_token_id=except_access_token_id,
         )
-        yield self.hs.get_pusherpool().remove_pushers_by_user(
-            user_id, except_access_token_id
-        )
 
     @defer.inlineCallbacks
     def deactivate_account(self, user_id):
@@ -706,6 +703,12 @@ class AuthHandler(BaseHandler):
                     access_token=access_token,
                 )
 
+        # delete pushers associated with this access token
+        if user_info["token_id"] is not None:
+            yield self.hs.get_pusherpool().remove_pushers_by_access_token(
+                str(user_info["user"]), (user_info["token_id"], )
+            )
+
     @defer.inlineCallbacks
     def delete_access_tokens_for_user(self, user_id, except_token_id=None,
                                       device_id=None):
@@ -728,13 +731,18 @@ class AuthHandler(BaseHandler):
         # see if any of our auth providers want to know about this
         for provider in self.password_providers:
             if hasattr(provider, "on_logged_out"):
-                for token, device_id in tokens_and_devices:
+                for token, token_id, device_id in tokens_and_devices:
                     yield provider.on_logged_out(
                         user_id=user_id,
                         device_id=device_id,
                         access_token=token,
                     )
 
+        # delete pushers associated with the access tokens
+        yield self.hs.get_pusherpool().remove_pushers_by_access_token(
+            user_id, (token_id for _, token_id, _ in tokens_and_devices),
+        )
+
     @defer.inlineCallbacks
     def add_threepid(self, user_id, medium, address, validated_at):
         # 'Canonicalise' email addresses down to lower case.