summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorHanadi <hanadi.tamimi@gmail.com>2023-09-13 14:33:39 +0200
committerGitHub <noreply@github.com>2023-09-13 08:33:39 -0400
commit7afb5e041004bab8b0aaf7909ce3c7a9ef80077f (patch)
tree567e71b3729378fdb41cba6b331e570f58c6459c /synapse/storage
parentUse StrCollection in additional places. (#16301) (diff)
downloadsynapse-7afb5e041004bab8b0aaf7909ce3c7a9ef80077f.tar.xz
Fix using dehydrated devices (MSC2697) & refresh tokens (#16288)
Refresh tokens were not correctly moved to the rehydrated
device (similar to how the access token is currently handled).
This resulted in invalid refresh tokens after rehydration.
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/databases/main/registration.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/synapse/storage/databases/main/registration.py b/synapse/storage/databases/main/registration.py
index 7e85b73e8e..e34156dc55 100644
--- a/synapse/storage/databases/main/registration.py
+++ b/synapse/storage/databases/main/registration.py
@@ -2312,6 +2312,26 @@ class RegistrationStore(StatsStore, RegistrationBackgroundUpdateStore):
 
         return next_id
 
+    async def set_device_for_refresh_token(
+        self, user_id: str, old_device_id: str, device_id: str
+    ) -> None:
+        """Moves refresh tokens from old device to current device
+
+        Args:
+            user_id: The user of the devices.
+            old_device_id: The old device.
+            device_id: The new device ID.
+        Returns:
+            None
+        """
+
+        await self.db_pool.simple_update(
+            "refresh_tokens",
+            keyvalues={"user_id": user_id, "device_id": old_device_id},
+            updatevalues={"device_id": device_id},
+            desc="set_device_for_refresh_token",
+        )
+
     def _set_device_for_access_token_txn(
         self, txn: LoggingTransaction, token: str, device_id: str
     ) -> str: