From 4cfc49c8bfbee329aaa94442c6bf15e9172683f3 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 15 Apr 2020 15:07:13 -0400 Subject: [PATCH] Ensure that UI auth stages are idempotent. --- synapse/storage/data_stores/main/ui_auth.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/synapse/storage/data_stores/main/ui_auth.py b/synapse/storage/data_stores/main/ui_auth.py index 0d179f375807..9245e9ce2e2c 100644 --- a/synapse/storage/data_stores/main/ui_auth.py +++ b/synapse/storage/data_stores/main/ui_auth.py @@ -94,13 +94,10 @@ async def mark_stage_complete( stage_type: The completed stage type. identity: The identity authenticated by the stage. """ - await self.db.simple_insert( + await self.db.simple_upsert( table="ui_auth_sessions_credentials", - values={ - "session_id": session_id, - "stage_type": stage_type, - "identity": json.dumps(identity), - }, + keyvalues={"session_id": session_id, "stage_type": stage_type}, + values={"identity": json.dumps(identity)}, desc="mark_stage_complete", )