Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Remove bound 3pids separately from locally associated 3pids
Browse files Browse the repository at this point in the history
It's possible for users to bind a 3pid without adding it to
a local association first, thus using `user_get_threepids` may not
result in all known bound
3pids. Which essentially culminates in us not unbinding all 3pids for
an account upon deactivation.

This commit separates unbinding bound 3pids and deleting local assocaitions into two separate steps.
  • Loading branch information
anoadragon453 committed Feb 13, 2023
1 parent a7fd5cb commit 17138e3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions synapse/handlers/deactivate_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ async def deactivate_account(
# unbinding
identity_server_supports_unbinding = True

# Remove any threepids associated with this account locally and attempt to
# unbind them from identity server(s).
threepids = await self.store.user_get_threepids(user_id)
for threepid in threepids:
# Attempt to unbind any known bound threepids to this account from identity
# server(s).
bound_threepids = await self.store.user_get_bound_threepids(user_id)
for threepid in bound_threepids:
try:
result = await self._auth_handler.delete_and_unbind_threepid(
user_id, threepid["medium"], threepid["address"], id_server
Expand All @@ -115,6 +115,13 @@ async def deactivate_account(

identity_server_supports_unbinding &= result

# Remove any local threepid associations for this account.
local_threepids = await self.store.user_get_threepids(user_id)
for threepid in local_threepids:
await self._auth_handler.delete_and_unbind_threepid(
user_id, threepid["medium"], threepid["address"], id_server
)

# delete any devices belonging to the user, which will also
# delete corresponding access tokens.
await self._device_handler.delete_all_devices_for_user(user_id)
Expand Down

0 comments on commit 17138e3

Please sign in to comment.