From d8e20104c843dc5a417f341f5ed586c6819bf8f4 Mon Sep 17 00:00:00 2001 From: Mathieu Velten Date: Wed, 28 Feb 2024 21:42:45 +0100 Subject: [PATCH] Remove auth provider external id association when deactivating an account --- synapse/handlers/deactivate_account.py | 2 ++ synapse/storage/databases/main/registration.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/synapse/handlers/deactivate_account.py b/synapse/handlers/deactivate_account.py index 370f4041fbc..4e35129e2d0 100644 --- a/synapse/handlers/deactivate_account.py +++ b/synapse/handlers/deactivate_account.py @@ -176,6 +176,8 @@ async def deactivate_account( # Remove account data (including ignored users and push rules). await self.store.purge_account_data_for_user(user_id) + await self.store.remove_external_ids_by_user(user_id) + # Delete any server-side backup keys await self.store.bulk_delete_backup_keys_and_versions_for_user(user_id) diff --git a/synapse/storage/databases/main/registration.py b/synapse/storage/databases/main/registration.py index 2c3f30e2eba..740008189e0 100644 --- a/synapse/storage/databases/main/registration.py +++ b/synapse/storage/databases/main/registration.py @@ -781,6 +781,15 @@ async def remove_user_external_id( desc="remove_user_external_id", ) + async def remove_external_ids_by_user(self, mxid: str) -> None: + await self.db_pool.simple_delete( + table="user_external_ids", + keyvalues={ + "user_id": mxid, + }, + desc="remove_external_ids_by_user", + ) + async def replace_user_external_id( self, record_external_ids: List[Tuple[str, str]],